From 7bcfa7e0e0c9fcf36feefe8f90fdecb53346a579 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Tue, 30 Apr 2024 20:11:52 +0400 Subject: [PATCH] op --- .../Models/Order.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs index ffb8b5e..bf50b41 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs @@ -51,7 +51,16 @@ namespace ComputerHardwareStoreDatabaseImplement.Models Status = model.Status, DateCreate = model.DateCreate, DateImplement = model.DateImplement, - Product = context.Products.First(x => x.Id == model.ProductId) + Products = context.Products + .Where(p => model.OrderProducts.ContainsKey(p.Id)) + .Select(p => new OrderProduct() + { + OrderId = model.Id, + ProductId = p.Id, + Product = p, + Count = model.OrderProducts[p.Id].Item2 + }) + .ToList() }; } public void Update(OrderBindingModel model) @@ -71,7 +80,5 @@ namespace ComputerHardwareStoreDatabaseImplement.Models DateCreate = DateCreate, DateImplement = DateImplement, }; - - public Dictionary OrderProduct => throw new NotImplementedException(); } } \ No newline at end of file