This commit is contained in:
Николай 2023-02-12 15:55:52 +04:00
parent 433410161d
commit 584401e1d6
3 changed files with 8 additions and 16 deletions

View File

@ -2,7 +2,6 @@
using FoodOrdersContracts.SearchModels;
using FoodOrdersContracts.StoragesContracts;
using FoodOrdersContracts.ViewModels;
using FoodOrdersFileImplement;
using FoodOrdersFileImplement.Models;
namespace FoodOrdersFileImplement.Implements

View File

@ -84,11 +84,11 @@ namespace FoodOrdersFileImplement.Models
new XElement("DishName", DishName),
new XElement("Price", Price.ToString()),
new XElement("DishComponents", Components.Select(x =>
new XElement("DishComponent",
new XElement("DishComponent",
new XElement("Key", x.Key),
new XElement("Key", x.Key),
new XElement("Value", x.Value)))
new XElement("Value", x.Value)))
.ToArray()));
}

View File

@ -23,23 +23,16 @@ namespace FoodOrdersFileImplement.Models
{
return null;
}
var order = new Order()
return new Order()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
DishId = Convert.ToInt32(element.Element("DishId")!.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 static Order? Create(OrderBindingModel? model)