From fd64893544ff5be11f2b8f80188aa7f229152259 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Tue, 21 May 2024 21:13:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=20=D1=81=D0=BD=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SushiBarFileImplement/Models/Order.cs | 4 ++++ .../Implements/OrderStorage.cs | 22 ++++++++++++------- .../SushiBarListImplement/Models/Order.cs | 5 ++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/SushiBar/SushiBarFileImplement/Models/Order.cs b/SushiBar/SushiBarFileImplement/Models/Order.cs index e70a3fe..31df23d 100644 --- a/SushiBar/SushiBarFileImplement/Models/Order.cs +++ b/SushiBar/SushiBarFileImplement/Models/Order.cs @@ -28,6 +28,7 @@ namespace SushiBarFileImplement.Models Id = model.Id, SushiId = model.SushiId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -46,6 +47,7 @@ namespace SushiBarFileImplement.Models Id = Convert.ToInt32(element.Attribute("Id")!.Value), SushiId = Convert.ToInt32(element.Element("SushiId")!.Value), ClientId = Convert.ToInt32(element.Element("ClientId")!.Value), + ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value.ToString()), @@ -68,6 +70,7 @@ namespace SushiBarFileImplement.Models Id = Id, SushiId = SushiId, ClientId = ClientId, + ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status, @@ -78,6 +81,7 @@ namespace SushiBarFileImplement.Models new XAttribute("Id", Id), new XElement("SushiId", SushiId), new XElement("ClientId", ClientId), + new XElement("ImplementerId", ClientId), new XElement("Count", Count), new XElement("Sum", Sum.ToString()), new XElement("Status", Status.ToString()), diff --git a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs index c285af1..1e699b1 100644 --- a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs @@ -18,7 +18,7 @@ namespace SushiBarListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(AccessClientStorage(AccessSushiStorage(order.GetViewModel))); + result.Add(AccessStorage(order.GetViewModel)); } return result; } @@ -31,7 +31,7 @@ namespace SushiBarListImplement.Implements (model.DateFrom.HasValue && model.DateTo.HasValue && model.DateFrom < order.DateCreate && order.DateCreate < model.DateTo)) { - result.Add(AccessClientStorage(AccessSushiStorage(order.GetViewModel))); + result.Add(AccessStorage(order.GetViewModel)); } } return result; @@ -46,7 +46,7 @@ namespace SushiBarListImplement.Implements { if (model.Id.HasValue && order.Id == model.Id) { - return AccessClientStorage(AccessSushiStorage(order.GetViewModel)); + return AccessStorage(order.GetViewModel); } } return null; @@ -67,7 +67,7 @@ namespace SushiBarListImplement.Implements return null; } _source.Orders.Add(newOrder); - return AccessClientStorage(AccessSushiStorage(newOrder.GetViewModel)); + return AccessStorage(newOrder.GetViewModel); } public OrderViewModel? Update(OrderBindingModel model) { @@ -76,7 +76,7 @@ namespace SushiBarListImplement.Implements if (order.Id == model.Id) { order.Update(model); - return AccessClientStorage(AccessSushiStorage(order.GetViewModel)); + return AccessStorage(order.GetViewModel); } } return null; @@ -89,7 +89,7 @@ namespace SushiBarListImplement.Implements { var element = _source.Orders[i]; _source.Orders.RemoveAt(i); - return AccessClientStorage(AccessSushiStorage(element.GetViewModel)); + return AccessStorage(element.GetViewModel); } } return null; @@ -107,11 +107,17 @@ namespace SushiBarListImplement.Implements return model; } - public OrderViewModel AccessClientStorage(OrderViewModel model) + public OrderViewModel AccessStorage(OrderViewModel model) { - var client = _source.Clients.FirstOrDefault(x => x.Id == model.ClientId); + var iceCream = _source.Sushis.FirstOrDefault(x => x.Id == model.Id); + var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id); + var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId); + if (iceCream != null) + model.SushiName = iceCream.SushiName; if (client != null) model.ClientFIO = client.ClientFIO; + if (implementer != null) + model.ImplementerName = implementer.ImplementerFIO; return model; } } diff --git a/SushiBar/SushiBarListImplement/Models/Order.cs b/SushiBar/SushiBarListImplement/Models/Order.cs index 0b6ca53..459a134 100644 --- a/SushiBar/SushiBarListImplement/Models/Order.cs +++ b/SushiBar/SushiBarListImplement/Models/Order.cs @@ -30,7 +30,8 @@ namespace SushiBarListImplement.Models Sum = model.Sum, Status = model.Status, DateCreate = model.DateCreate, - DateImplement = model.DateImplement + DateImplement = model.DateImplement, + ImplementerId = model.ImplementerId }; } public void Update(OrderBindingModel? model) @@ -41,6 +42,7 @@ namespace SushiBarListImplement.Models } SushiId = model.SushiId; ClientId = model.ClientId; + ImplementerId = model.ImplementerId; Count = model.Count; Sum = model.Sum; Status = model.Status; @@ -51,6 +53,7 @@ namespace SushiBarListImplement.Models Id = Id, SushiId = SushiId, ClientId = ClientId, + ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status,