diff --git a/AutoWorkshop.sln b/AutoWorkshop.sln
index 8b77230..fb90b42 100644
--- a/AutoWorkshop.sln
+++ b/AutoWorkshop.sln
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopBusinessLogic",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopListImplement", "AutoWorkshopImplement\AutoWorkshopListImplement.csproj", "{B564F5E8-2F14-4816-8481-1F9649F1F414}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopFileImplement", "AutoWorkshopFileImplement\AutoWorkshopFileImplement.csproj", "{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{B564F5E8-2F14-4816-8481-1F9649F1F414}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B564F5E8-2F14-4816-8481-1F9649F1F414}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B564F5E8-2F14-4816-8481-1F9649F1F414}.Release|Any CPU.Build.0 = Release|Any CPU
+ {862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/AutoWorkshopFileImplement/AutoWorkshopFileImplement.csproj b/AutoWorkshopFileImplement/AutoWorkshopFileImplement.csproj
new file mode 100644
index 0000000..6deaaf6
--- /dev/null
+++ b/AutoWorkshopFileImplement/AutoWorkshopFileImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/AutoWorkshopFileImplement/DataFileSingleton.cs b/AutoWorkshopFileImplement/DataFileSingleton.cs
new file mode 100644
index 0000000..266f506
--- /dev/null
+++ b/AutoWorkshopFileImplement/DataFileSingleton.cs
@@ -0,0 +1,59 @@
+using AutoWorkshopFileImplement.Models;
+using System.Xml.Linq;
+
+namespace AutoWorkshopFileImplement
+{
+ public class DataFileSingleton
+ {
+ private static DataFileSingleton? _instance;
+
+ private readonly string ComponentFileName = "Component.xml";
+ private readonly string OrderFileName = "Order.xml";
+ private readonly string RepairFileName = "Repair.xml";
+
+ public List Components { get; private set; }
+
+ public List Orders { get; private set; }
+
+ public List Repairs { get; private set; }
+
+ private DataFileSingleton()
+ {
+ Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
+ Repairs = LoadData(RepairFileName, "Repair", x => Repair.Create(x)!)!;
+ Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
+ }
+
+ public static DataFileSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataFileSingleton();
+ }
+
+ return _instance;
+ }
+
+ public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
+ public void SaveRepairs() => SaveData(Repairs, RepairFileName, "Repairs", x => x.GetXElement);
+ public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
+
+ 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/AutoWorkshopFileImplement/Models/Component.cs b/AutoWorkshopFileImplement/Models/Component.cs
new file mode 100644
index 0000000..383028b
--- /dev/null
+++ b/AutoWorkshopFileImplement/Models/Component.cs
@@ -0,0 +1,65 @@
+using AutoWorkshopContracts.BindingModels;
+using AutoWorkshopContracts.ViewModels;
+using AutoWorkshopDataModels.Models;
+using System.Xml.Linq;
+
+namespace AutoWorkshopFileImplement.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 is null)
+ return null;
+
+ return new Component()
+ {
+ Id = Model.Id,
+ ComponentName = Model.ComponentName,
+ Cost = Model.Cost
+ };
+ }
+
+ public static Component? Create(XElement Element)
+ {
+ if (Element is 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 is 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())
+ );
+ }
+}
diff --git a/AutoWorkshopFileImplement/Models/Order.cs b/AutoWorkshopFileImplement/Models/Order.cs
new file mode 100644
index 0000000..97a67fd
--- /dev/null
+++ b/AutoWorkshopFileImplement/Models/Order.cs
@@ -0,0 +1,90 @@
+using AutoWorkshopContracts.BindingModels;
+using AutoWorkshopContracts.ViewModels;
+using AutoWorkshopDataModels.Enums;
+using AutoWorkshopDataModels.Models;
+using System.Xml.Linq;
+
+namespace AutoWorkshopFileImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+
+ public int RepairId { get; private set; }
+
+ public int Count { get; private set; }
+
+ public double Sum { get; private set; }
+
+ public OrderStatus Status { get; private set; }
+
+ public DateTime DateCreate { get; private set; }
+
+ public DateTime? DateImplement { get; private set; }
+
+ public static Order? Create(OrderBindingModel? Model)
+ {
+ if (Model is null)
+ return null;
+
+ return new Order()
+ {
+ Id = Model.Id,
+ RepairId = Model.RepairId,
+ Count = Model.Count,
+ Sum = Model.Sum,
+ Status = Model.Status,
+ DateCreate = Model.DateCreate,
+ DateImplement = Model.DateImplement
+ };
+ }
+
+ public static Order? Create(XElement Element)
+ {
+ if (Element is null)
+ return null;
+
+ return new Order()
+ {
+ Id = Convert.ToInt32(Element.Attribute("Id")!.Value),
+ RepairId = Convert.ToInt32(Element.Element("RepairId")!.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 = 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)
+ {
+ if (Model is null)
+ return;
+
+ Status = Model.Status;
+ DateImplement = Model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ RepairId = RepairId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+
+ public XElement GetXElement => new(
+ "Order",
+ new XAttribute("Id", Id),
+ new XElement("RepairId", RepairId),
+ new XElement("Count", Count.ToString()),
+ new XElement("Sum", Sum.ToString()),
+ new XElement("Status", Status.ToString()),
+ new XElement("DateCreate", DateCreate.ToString()),
+ new XElement("DateImplement", DateImplement.ToString())
+ );
+ }
+}
diff --git a/AutoWorkshopFileImplement/Models/Repair.cs b/AutoWorkshopFileImplement/Models/Repair.cs
new file mode 100644
index 0000000..7907ac6
--- /dev/null
+++ b/AutoWorkshopFileImplement/Models/Repair.cs
@@ -0,0 +1,87 @@
+using AutoWorkshopContracts.BindingModels;
+using AutoWorkshopContracts.ViewModels;
+using AutoWorkshopDataModels.Models;
+using System.Xml.Linq;
+
+namespace AutoWorkshopFileImplement.Models
+{
+ public class Repair : IRepairModel
+ {
+ public int Id { get; private set; }
+
+ public string RepairName { get; private set; } = string.Empty;
+
+ public double Price { get; private set; }
+
+ public Dictionary Components { get; private set; } = new();
+
+ private Dictionary? _RepairComponents = null;
+
+ public Dictionary RepairComponents
+ {
+ get
+ {
+ if (_RepairComponents == null)
+ {
+ var source = DataFileSingleton.GetInstance();
+ _RepairComponents = Components.ToDictionary(x => x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
+ }
+ return _RepairComponents;
+ }
+ }
+
+ public static Repair? Create(RepairBindingModel Model)
+ {
+ if (Model is null)
+ return null;
+
+ return new Repair()
+ {
+ Id = Model.Id,
+ RepairName = Model.RepairName,
+ Price = Model.Price,
+ Components = Model.RepairComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
+ };
+ }
+ public static Repair? Create(XElement Element)
+ {
+ if (Element is null)
+ return null;
+
+ return new Repair()
+ {
+ Id = Convert.ToInt32(Element.Attribute("Id")!.Value),
+ RepairName = Element.Element("RepairName")!.Value,
+ Price = Convert.ToDouble(Element.Element("Price")!.Value),
+ Components = Element.Element("RepairComponents")!.Elements("RepairComponent").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
+ };
+ }
+
+ public void Update(RepairBindingModel Model)
+ {
+ if (Model is null)
+ return;
+
+ RepairName = Model.RepairName;
+ Price = Model.Price;
+ Components = Model.RepairComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
+ _RepairComponents = null;
+ }
+
+ public RepairViewModel GetViewModel => new()
+ {
+ Id = Id,
+ RepairName = RepairName,
+ Price = Price,
+ RepairComponents = RepairComponents
+ };
+
+ public XElement GetXElement => new(
+ "Repair",
+ new XAttribute("Id", Id),
+ new XElement("RepairName", RepairName),
+ new XElement("Price", Price.ToString()),
+ new XElement("RepairComponents", Components.Select(x => new XElement("RepairComponent", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray())
+ );
+ }
+}
diff --git a/AutoWorkshopView/AutoWorkshopView.csproj b/AutoWorkshopView/AutoWorkshopView.csproj
index 3a78229..be1364a 100644
--- a/AutoWorkshopView/AutoWorkshopView.csproj
+++ b/AutoWorkshopView/AutoWorkshopView.csproj
@@ -10,6 +10,7 @@
+
diff --git a/Задание.pdf b/Задание.pdf
new file mode 100644
index 0000000..0c6564e
Binary files /dev/null and b/Задание.pdf differ