diff --git a/Confectionery/ConfectioneryFileImplement/Component.cs b/Confectionery/ConfectioneryFileImplement/Component.cs
deleted file mode 100644
index 63e6867..0000000
--- a/Confectionery/ConfectioneryFileImplement/Component.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System.ComponentModel;
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDataModels.Models;
-using System.Xml.Linq;
-
-namespace ConfectioneryFileImplement.Models
-{
- public class Component : IComponentModel
- {
- public int Id { get; private set; }
- public string ComponentName { get; private set; } = string.Empty;
- public double Cost { get; set; }
- public static Component? Create(ComponentBindingModel model)
- {
- if (model == null)
- {
- return null;
- }
- return new Component()
- {
- Id = model.Id,
- ComponentName = model.ComponentName,
- Cost = model.Cost
- };
- }
- public static Component? Create(XElement element)
- {
- if (element == null)
- {
- return null;
- }
- return new Component()
- {
- Id = Convert.ToInt32(element.Attribute("Id")!.Value),
- ComponentName = element.Element("ComponentName")!.Value,
- Cost = Convert.ToDouble(element.Element("Cost")!.Value)
- };
- }
- public void Update(ComponentBindingModel model)
- {
- if (model == null)
- {
- return;
- }
- ComponentName = model.ComponentName;
- Cost = model.Cost;
- }
- public ComponentViewModel GetViewModel => new()
- {
- Id = Id,
- ComponentName = ComponentName,
- Cost = Cost
- };
- public XElement GetXElement => new("Component",
- new XAttribute("Id", Id),
- new XElement("ComponentName", ComponentName),
- new XElement("Cost", Cost.ToString()));
- }
-}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryFileImplement/ConfectioneryFileImplement.csproj b/Confectionery/ConfectioneryFileImplement/ConfectioneryFileImplement.csproj
deleted file mode 100644
index 54e27de..0000000
--- a/Confectionery/ConfectioneryFileImplement/ConfectioneryFileImplement.csproj
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- net6.0
- enable
- enable
-
-
-
-
-
-
-
-
diff --git a/Confectionery/ConfectioneryFileImplement/DataFileSilgleton.cs b/Confectionery/ConfectioneryFileImplement/DataFileSilgleton.cs
deleted file mode 100644
index 06fb502..0000000
--- a/Confectionery/ConfectioneryFileImplement/DataFileSilgleton.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using ConfectioneryFileImplement.Models;
-using System.Xml.Linq;
-
-namespace PastryShopFileImplement
-{
- internal class DataFileSingleton
- {
- private static DataFileSingleton? instance;
-
- private readonly string ComponentFileName = "Component.xml";
-
- private readonly string OrderFileName = "Order.xml";
-
- private readonly string PastryFileName = "Pastry.xml";
-
- public List Components { get; private set; }
-
- public List Orders { get; private set; }
-
- public List Pastrys { get; private set; }
-
- public static DataFileSingleton GetInstance()
- {
- if (instance == null)
- {
- instance = new DataFileSingleton();
- }
- return instance;
- }
-
- public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
-
- public void SavePastrys() => SaveData(Pastrys, PastryFileName, "Pastrys", x => x.GetXElement);
-
- public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
-
- private DataFileSingleton()
- {
- Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
- 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)
- {
- if (File.Exists(filename))
- {
- return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
- }
- return new List();
- }
-
- 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);
- }
- }
- }
-}
diff --git a/Confectionery/ConfectioneryFileImplement/Pastry.cs b/Confectionery/ConfectioneryFileImplement/Pastry.cs
deleted file mode 100644
index 20602d5..0000000
--- a/Confectionery/ConfectioneryFileImplement/Pastry.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using ConfectioneryDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml.Linq;
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-
-
-namespace ConfectioneryFileImplement.Models
-{
- public class Pastry : IPastryModel
- {
- public int Id { get; private set; }
- public string PastryName { get; private set; } = string.Empty;
- public double Price { get; private set; }
- public Dictionary Components { get; private set; } = new();
- private Dictionary? _PastryComponents =
- null;
- public Dictionary PastryComponents
- {
- get
- {
- if (_PastryComponents == null)
- {
- var source = DataFileSingleton.GetInstance();
- _PastryComponents = Components.ToDictionary(x => x.Key, y =>
- ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!,
- y.Value));
- }
- return _PastryComponents;
- }
- }
- public static Pastry? Create(PastryBindingModel model)
- {
- if (model == null)
- {
- return null;
- }
- return new Pastry()
- {
- Id = model.Id,
- PastryName = model.PastryName,
- Price = model.Price,
- Components = model.PastryComponents.ToDictionary(x => x.Key, x
- => x.Value.Item2)
- };
- }
- public static Pastry? Create(XElement element)
- {
- if (element == null)
- {
- return null;
- }
- return new Pastry()
- {
- 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))
- };
- }
- public void Update(PastryBindingModel model)
- {
- if (model == null)
- {
- return;
- }
- PastryName = model.PastryName;
- Price = model.Price;
- Components = model.PastryComponents.ToDictionary(x => x.Key, x =>
- x.Value.Item2);
- _PastryComponents = null;
- }
- public PastryViewModel GetViewModel => new()
- {
- Id = Id,
- PastryName = PastryName,
- Price = Price,
- PastryComponents = PastryComponents
- };
- public XElement GetXElement => new("Pastry",
- new XAttribute("Id", Id),
- new XElement("PastryName", PastryName),
- new XElement("Price", Price.ToString()),
- new XElement("PastryComponents", Components.Select(x =>
- new XElement("PastryComponent",
-
- new XElement("Key", x.Key),
-
- new XElement("Value", x.Value)))
-
- .ToArray()));
-
- }
-}