From 40637ffd0f5f87b8598f878d0857e127be05a136 Mon Sep 17 00:00:00 2001 From: revengel66 Date: Wed, 13 Mar 2024 00:15:17 +0400 Subject: [PATCH] end lab2 --- Pizzeria/AbstractShopFileImplement/Models/Order.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Pizzeria/AbstractShopFileImplement/Models/Order.cs b/Pizzeria/AbstractShopFileImplement/Models/Order.cs index 53a27e4..80c8370 100644 --- a/Pizzeria/AbstractShopFileImplement/Models/Order.cs +++ b/Pizzeria/AbstractShopFileImplement/Models/Order.cs @@ -50,9 +50,9 @@ namespace PizzeriaFileImplement.Models PizzaId = Convert.ToInt32(element.Element("PizzaId")!.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), - DateCreate = DateTime.Parse(element.Element("DateCreate")!.Value), - DateImplement = DateTime.Parse(element.Element("DateImplement")!.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) }; } public void Update(OrderBindingModel? model) @@ -76,7 +76,7 @@ namespace PizzeriaFileImplement.Models DateImplement = DateImplement }; - public XElement GetXElement => new("Component", + public XElement GetXElement => new("Order", new XAttribute("Id", Id), new XElement("PizzaId", PizzaId), new XElement("Count", Count.ToString()),