From b91edc375c284288c5f45bc3db87ea92814f6dc6 Mon Sep 17 00:00:00 2001 From: dasha Date: Sun, 12 Feb 2023 16:00:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBarFileImplement/Models/Order.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/SushiBar/SushiBarFileImplement/Models/Order.cs b/SushiBar/SushiBarFileImplement/Models/Order.cs index 6d1f581..3f8160b 100644 --- a/SushiBar/SushiBarFileImplement/Models/Order.cs +++ b/SushiBar/SushiBarFileImplement/Models/Order.cs @@ -39,23 +39,16 @@ namespace SushiBarFileImplement.Models { return null; } - var order = new Order() + return new Order() { Id = Convert.ToInt32(element.Attribute("Id")!.Value), SushiId = Convert.ToInt32(element.Element("SushiId")!.Value), - Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), - DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null), + Count = Convert.ToInt32(element.Element("Count")!.Value), + Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), + DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value), + DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(element.Element("DateImplement")!.Value) }; - DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl); - order.DateImplement = dateImpl; - - if (!Enum.TryParse(element.Element("Status")!.Value, out OrderStatus status)) - { - return null; - } - order.Status = status; - return order; } public void Update(OrderBindingModel? model)