Assembly orders 2

This commit is contained in:
the 2023-05-18 18:33:33 +04:00
parent 1a849e4fbd
commit 49b8f15517
3 changed files with 18 additions and 1 deletions

View File

@ -18,5 +18,10 @@ namespace ComputerShopContracts.BindingModels
get; get;
set; set;
} = new(); } = new();
public Dictionary<int, (IOrderModel, int)> AssemblyOrders
{
get;
set;
} = new();
} }
} }

View File

@ -21,6 +21,11 @@ namespace ComputerShopContracts.ViewModels
get; get;
set; set;
} = new(); } = new();
public Dictionary<int, (IOrderModel, int)> AssemblyOrders
{
get;
set;
} = new();
public int ClientId { get; set; } public int ClientId { get; set; }
[DisplayName("ФИО клиента")] [DisplayName("ФИО клиента")]

View File

@ -39,7 +39,7 @@ namespace ComputerShopDatabaseImplement.Models
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null; private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
[NotMapped] [NotMapped]
public Dictionary<int, (IOrderModel, int)> AssemblyPrders public Dictionary<int, (IOrderModel, int)> AssemblyOrders
{ {
get get
{ {
@ -70,6 +70,12 @@ namespace ComputerShopDatabaseImplement.Models
{ {
Component = context.Components.First(y => y.Id == x.Key), Component = context.Components.First(y => y.Id == x.Key),
Count = x.Value.Item2 Count = x.Value.Item2
}).ToList(),
Orders = model.AssemblyOrders.Select(x => new
AssemblyOrder
{
Order = context.Orders.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList() }).ToList()
}; };
} }
@ -84,6 +90,7 @@ namespace ComputerShopDatabaseImplement.Models
AssemblyName = AssemblyName, AssemblyName = AssemblyName,
Price = Price, Price = Price,
AssemblyComponents = AssemblyComponents, AssemblyComponents = AssemblyComponents,
AssemblyOrders = AssemblyOrders,
ClientId = ClientId ClientId = ClientId
}; };
public void UpdateComponents(ComputerShopDatabase context, AssemblyBindingModel model) public void UpdateComponents(ComputerShopDatabase context, AssemblyBindingModel model)