Added missing field to display price of products on quotation and purchase order
This commit is contained in:
@@ -6,6 +6,6 @@ public class GetPurchaseOrderDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? PurchaseConditions { get; set; }
|
||||
public int SupplierId { get; set; }
|
||||
public string? SupplierName { get; set; }
|
||||
public List<GetPurchaseProductDto>? Products { get; set; }
|
||||
}
|
||||
@@ -15,5 +15,6 @@ public class GetQuotationProductDto
|
||||
public string? ProductImage { get; set; }
|
||||
public string? ProductLink { get; set; }
|
||||
public int ProductMinimalQuantity { get; set; }
|
||||
public decimal ProductPrice { get; set; }
|
||||
public int QuotationId { get; set; }
|
||||
}
|
||||
@@ -35,15 +35,22 @@ public class EntityToDtoMappings : Profile
|
||||
CreateMap<ProductDelivery, GetProductDeliveryDto>();
|
||||
|
||||
CreateMap<PurchaseOrder, GetPurchaseOrderDto>()
|
||||
.ForMember(dest => dest.SupplierName, opt => opt.MapFrom(src => src.Supplier!.Name))
|
||||
.ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.PurchaseProducts));
|
||||
|
||||
CreateMap<PurchaseProduct, GetPurchaseProductDto>();
|
||||
CreateMap<PurchaseProduct, GetPurchaseProductDto>()
|
||||
.ForMember(dest => dest.ProductPrice,
|
||||
opt => opt.MapFrom(src =>
|
||||
src.Product!.Prices.Where(x => x.SupplierId == src.PurchaseOrder!.SupplierId && x.ProductId == src.ProductId).Select(x => x.SellingPrice).FirstOrDefault()));
|
||||
|
||||
CreateMap<Quotation, GetQuotationDto>()
|
||||
.ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.QuotationProducts));
|
||||
|
||||
CreateMap<QuotationProduct, GetQuotationProductDto>();
|
||||
|
||||
CreateMap<QuotationProduct, GetQuotationProductDto>()
|
||||
.ForMember(dest => dest.ProductPrice,
|
||||
opt => opt.MapFrom(src =>
|
||||
src.Product!.Prices.Where(x => x.SupplierId == src.Quotation!.SupplierId && x.ProductId == src.ProductId).Select(x => x.SellingPrice).FirstOrDefault()));
|
||||
|
||||
CreateMap<Setting, GetSettingDto>();
|
||||
|
||||
CreateMap<User, GetUserDto>();
|
||||
|
||||
+2000
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PyroFetes.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddedMissingFieldForSupplierInDocuments : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "SupplierId",
|
||||
table: "Quotations",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Quotations_SupplierId",
|
||||
table: "Quotations",
|
||||
column: "SupplierId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Quotations_Suppliers_SupplierId",
|
||||
table: "Quotations",
|
||||
column: "SupplierId",
|
||||
principalTable: "Suppliers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Quotations_Suppliers_SupplierId",
|
||||
table: "Quotations");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Quotations_SupplierId",
|
||||
table: "Quotations");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SupplierId",
|
||||
table: "Quotations");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -744,10 +744,15 @@ namespace PyroFetes.Migrations
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.Property<int>("SupplierId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CustomerId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Quotations");
|
||||
});
|
||||
|
||||
@@ -1553,7 +1558,7 @@ namespace PyroFetes.Migrations
|
||||
modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b =>
|
||||
{
|
||||
b.HasOne("PyroFetes.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.WithMany("PurchaseOrders")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@@ -1588,7 +1593,15 @@ namespace PyroFetes.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PyroFetes.Models.Supplier", "Supplier")
|
||||
.WithMany("Quotations")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Customer");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b =>
|
||||
@@ -1957,6 +1970,10 @@ namespace PyroFetes.Migrations
|
||||
modelBuilder.Entity("PyroFetes.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Prices");
|
||||
|
||||
b.Navigation("PurchaseOrders");
|
||||
|
||||
b.Navigation("Quotations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PyroFetes.Models.Truck", b =>
|
||||
|
||||
@@ -10,6 +10,9 @@ public class Quotation
|
||||
|
||||
[Required] public int CustomerId { get; set; }
|
||||
public Customer? Customer { get; set; }
|
||||
|
||||
[Required] public int SupplierId { get; set; }
|
||||
public Supplier? Supplier { get; set; }
|
||||
|
||||
public List<QuotationProduct>? QuotationProducts { get; set; }
|
||||
}
|
||||
@@ -13,5 +13,7 @@ public class Supplier
|
||||
[Required, MaxLength(100)] public string? City { get; set; }
|
||||
[Required] public int DeliveryDelay { get; set; }
|
||||
|
||||
public List<Price>? Prices { get; set; }
|
||||
public List<Price>? Prices { get; set; }
|
||||
public List<Quotation>? Quotations { get; set; }
|
||||
public List<PurchaseOrder>? PurchaseOrders { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user