diff --git a/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs b/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs index b54cfeb..939a2cc 100644 --- a/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs +++ b/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs @@ -37,8 +37,7 @@ namespace ConfectioneryFileImplement Pastrys = LoadData(PastryFileName, "Pastry", x => Pastry.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; } - private static List? LoadData(string filename, string xmlNodeName, - Func selectFunction) + private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) { if (File.Exists(filename)) { @@ -47,13 +46,11 @@ namespace ConfectioneryFileImplement } return new List(); } - private static void SaveData(List data, string filename, string - xmlNodeName, Func selectFunction) + private static void SaveData(List data, string filename, string xmlNodeName, Func selectFunction) { if (data != null) { - new XDocument(new XElement(xmlNodeName, - data.Select(selectFunction).ToArray())).Save(filename); + new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename); } } } diff --git a/Confectionery/ConfectioneryFileImplement/OrderStorage.cs b/Confectionery/ConfectioneryFileImplement/OrderStorage.cs index 66954d5..0ca29d8 100644 --- a/Confectionery/ConfectioneryFileImplement/OrderStorage.cs +++ b/Confectionery/ConfectioneryFileImplement/OrderStorage.cs @@ -83,10 +83,10 @@ namespace ConfectioneryFileImplement.Implements { return null; } - var pizza = source.Pastrys.FirstOrDefault(x => x.Id == model.PastryId); - if (pizza != null) + var pastry = source.Pastrys.FirstOrDefault(x => x.Id == model.PastryId); + if (pastry != null) { - model.PastryName = pizza.PastryName; + model.PastryName = pastry.PastryName; } return model; } diff --git a/Confectionery/ConfectioneryFileImplement/Pastry.cs b/Confectionery/ConfectioneryFileImplement/Pastry.cs index a82b204..7611b91 100644 --- a/Confectionery/ConfectioneryFileImplement/Pastry.cs +++ b/Confectionery/ConfectioneryFileImplement/Pastry.cs @@ -58,11 +58,8 @@ namespace ConfectioneryFileImplement.Models Id = Convert.ToInt32(element.Attribute("Id")!.Value), PastryName = element.Element("PastryName")!.Value, Price = Convert.ToDouble(element.Element("Price")!.Value), - Components = -element.Element("PastryComponents")!.Elements("PastryComponent") - .ToDictionary(x => -Convert.ToInt32(x.Element("Key")?.Value), x => -Convert.ToInt32(x.Element("Value")?.Value)) + Components = element.Element("PastryComponents")!.Elements("PastryComponent").ToDictionary + (x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value)) }; } public void Update(PastryBindingModel model) @@ -73,8 +70,7 @@ Convert.ToInt32(x.Element("Value")?.Value)) } PastryName = model.PastryName; Price = model.Price; - Components = model.PastryComponents.ToDictionary(x => x.Key, x => - x.Value.Item2); + Components = model.PastryComponents.ToDictionary(x => x.Key, x => x.Value.Item2); _pastryComponents = null; } public PastryViewModel GetViewModel => new()