diff --git a/Bar/Bar.sln b/Bar/Bar.sln
index ae8b540..c7521ef 100644
--- a/Bar/Bar.sln
+++ b/Bar/Bar.sln
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarDataModels", "BarDataMod
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarListImplement", "BarListImplement\BarListImplement\BarListImplement.csproj", "{FE39065B-D1CA-4CF4-9274-2160A26F8A68}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarFileImplement", "BarFileImplement\BarFileImplement\BarFileImplement.csproj", "{7B4E6858-4E4D-4D64-B9D4-536F8EC52412}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{FE39065B-D1CA-4CF4-9274-2160A26F8A68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE39065B-D1CA-4CF4-9274-2160A26F8A68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE39065B-D1CA-4CF4-9274-2160A26F8A68}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7B4E6858-4E4D-4D64-B9D4-536F8EC52412}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7B4E6858-4E4D-4D64-B9D4-536F8EC52412}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7B4E6858-4E4D-4D64-B9D4-536F8EC52412}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7B4E6858-4E4D-4D64-B9D4-536F8EC52412}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Bar/Bar/BarView.csproj b/Bar/Bar/BarView.csproj
index a32b51e..2d2734a 100644
--- a/Bar/Bar/BarView.csproj
+++ b/Bar/Bar/BarView.csproj
@@ -16,6 +16,7 @@
+
@@ -24,5 +25,5 @@
Always
-
+
\ No newline at end of file
diff --git a/Bar/Bar/FormMain.Designer.cs b/Bar/Bar/FormMain.Designer.cs
index 59d2b32..c41b570 100644
--- a/Bar/Bar/FormMain.Designer.cs
+++ b/Bar/Bar/FormMain.Designer.cs
@@ -44,7 +44,7 @@
//
// CreateOrderButton
//
- this.CreateOrderButton.Location = new System.Drawing.Point(1073, 93);
+ this.CreateOrderButton.Location = new System.Drawing.Point(1075, 90);
this.CreateOrderButton.Name = "CreateOrderButton";
this.CreateOrderButton.Size = new System.Drawing.Size(194, 40);
this.CreateOrderButton.TabIndex = 9;
@@ -54,7 +54,7 @@
//
// TakeInWorkButton
//
- this.TakeInWorkButton.Location = new System.Drawing.Point(1073, 148);
+ this.TakeInWorkButton.Location = new System.Drawing.Point(1075, 145);
this.TakeInWorkButton.Name = "TakeInWorkButton";
this.TakeInWorkButton.Size = new System.Drawing.Size(194, 40);
this.TakeInWorkButton.TabIndex = 10;
@@ -64,7 +64,7 @@
//
// ReadyButton
//
- this.ReadyButton.Location = new System.Drawing.Point(1073, 207);
+ this.ReadyButton.Location = new System.Drawing.Point(1075, 204);
this.ReadyButton.Name = "ReadyButton";
this.ReadyButton.Size = new System.Drawing.Size(194, 40);
this.ReadyButton.TabIndex = 11;
@@ -74,7 +74,7 @@
//
// IssuedButton
//
- this.IssuedButton.Location = new System.Drawing.Point(1073, 264);
+ this.IssuedButton.Location = new System.Drawing.Point(1075, 261);
this.IssuedButton.Name = "IssuedButton";
this.IssuedButton.Size = new System.Drawing.Size(194, 40);
this.IssuedButton.TabIndex = 12;
@@ -84,7 +84,7 @@
//
// RefreshButton
//
- this.RefreshButton.Location = new System.Drawing.Point(1073, 325);
+ this.RefreshButton.Location = new System.Drawing.Point(1075, 322);
this.RefreshButton.Name = "RefreshButton";
this.RefreshButton.Size = new System.Drawing.Size(194, 40);
this.RefreshButton.TabIndex = 13;
@@ -99,7 +99,7 @@
this.DataGridView.Name = "DataGridView";
this.DataGridView.RowHeadersWidth = 51;
this.DataGridView.RowTemplate.Height = 29;
- this.DataGridView.Size = new System.Drawing.Size(1029, 362);
+ this.DataGridView.Size = new System.Drawing.Size(1042, 362);
this.DataGridView.TabIndex = 14;
//
// menuStrip1
@@ -109,7 +109,7 @@
this.ToolStripMenu});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(1279, 28);
+ this.menuStrip1.Size = new System.Drawing.Size(1283, 28);
this.menuStrip1.TabIndex = 15;
this.menuStrip1.Text = "menuStrip1";
//
@@ -140,7 +140,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1279, 450);
+ this.ClientSize = new System.Drawing.Size(1283, 450);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.DataGridView);
this.Controls.Add(this.RefreshButton);
diff --git a/Bar/Bar/Program.cs b/Bar/Bar/Program.cs
index b49921e..e0c18a0 100644
--- a/Bar/Bar/Program.cs
+++ b/Bar/Bar/Program.cs
@@ -1,7 +1,7 @@
using BarBusinessLogic.BusinessLogics;
using BarContracts.BusinessLogicContracts;
using BarContracts.StoragesContracts;
-using BarListImplement.Implements;
+using BarFileImplement.Implements;
using BarView.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
diff --git a/Bar/BarFileImplement/BarFileImplement.sln b/Bar/BarFileImplement/BarFileImplement.sln
new file mode 100644
index 0000000..cbc0414
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32210.238
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BarFileImplement", "BarFileImplement\BarFileImplement.csproj", "{7C01837C-759E-45DB-9EFA-43624DB7F854}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7C01837C-759E-45DB-9EFA-43624DB7F854}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7C01837C-759E-45DB-9EFA-43624DB7F854}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7C01837C-759E-45DB-9EFA-43624DB7F854}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7C01837C-759E-45DB-9EFA-43624DB7F854}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A6DD727D-364E-497D-AC71-AC019A610B92}
+ EndGlobalSection
+EndGlobal
diff --git a/Bar/BarFileImplement/BarFileImplement/BarFileImplement.csproj b/Bar/BarFileImplement/BarFileImplement/BarFileImplement.csproj
new file mode 100644
index 0000000..d446852
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/BarFileImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/Bar/BarFileImplement/BarFileImplement/DataFileSingleton.cs b/Bar/BarFileImplement/BarFileImplement/DataFileSingleton.cs
new file mode 100644
index 0000000..e847f0c
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/DataFileSingleton.cs
@@ -0,0 +1,59 @@
+using BarFileImplement.Models;
+using System.Xml.Linq;
+
+namespace BarFileImplement
+{
+ public class DataFileSingleton
+ {
+ private static DataFileSingleton? _instance;
+
+ private readonly string ComponentFileName = "Component.xml";
+ private readonly string OrderFileName = "Order.xml";
+ private readonly string CocktailFileName = "Cocktail.xml";
+
+ public List Components { get; private set; }
+
+ public List Orders { get; private set; }
+
+ public List Cocktails { get; private set; }
+
+ private DataFileSingleton()
+ {
+ Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
+ Cocktails = LoadData(CocktailFileName, "Cocktail", x => Cocktail.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 SaveCocktails() => SaveData(Cocktails, CocktailFileName, "Cocktails", 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/Bar/BarFileImplement/BarFileImplement/Implements/CocktailStorage.cs b/Bar/BarFileImplement/BarFileImplement/Implements/CocktailStorage.cs
new file mode 100644
index 0000000..95c892b
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/Implements/CocktailStorage.cs
@@ -0,0 +1,80 @@
+using BarContracts.BindingModels;
+using BarContracts.SearchModels;
+using BarContracts.StoragesContracts;
+using BarContracts.ViewModels;
+using BarFileImplement.Models;
+
+namespace BarFileImplement.Implements
+{
+ public class CocktailStorage : ICocktailStorage
+ {
+ private readonly DataFileSingleton _source;
+
+ public CocktailStorage()
+ {
+ _source = DataFileSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ return _source.Cocktails.Select(x => x.GetViewModel).ToList();
+ }
+
+ public List GetFilteredList(CocktailSearchModel Model)
+ {
+ if (string.IsNullOrEmpty(Model.CocktailName))
+ return new();
+
+ return _source.Cocktails.Where(x => x.CocktailName.Contains(Model.CocktailName)).Select(x => x.GetViewModel).ToList();
+ }
+
+ public CocktailViewModel? GetElement(CocktailSearchModel Model)
+ {
+ if (string.IsNullOrEmpty(Model.CocktailName) && !Model.Id.HasValue)
+ return null;
+
+ return _source.Cocktails.FirstOrDefault(x => (!string.IsNullOrEmpty(Model.CocktailName) && x.CocktailName == Model.CocktailName) || (Model.Id.HasValue && x.Id == Model.Id))?.GetViewModel;
+ }
+
+ public CocktailViewModel? Insert(CocktailBindingModel Model)
+ {
+ Model.Id = _source.Cocktails.Count > 0 ? _source.Cocktails.Max(x => x.Id) + 1 : 1;
+
+ var NewCocktail = Cocktail.Create(Model);
+
+ if (NewCocktail == null)
+ return null;
+
+ _source.Cocktails.Add(NewCocktail);
+ _source.SaveCocktails();
+
+ return NewCocktail.GetViewModel;
+ }
+
+ public CocktailViewModel? Update(CocktailBindingModel Model)
+ {
+ var Cocktail = _source.Cocktails.FirstOrDefault(x => x.Id == Model.Id);
+
+ if (Cocktail == null)
+ return null;
+
+ Cocktail.Update(Model);
+ _source.SaveCocktails();
+
+ return Cocktail.GetViewModel;
+ }
+
+ public CocktailViewModel? Delete(CocktailBindingModel Model)
+ {
+ var Cocktail = _source.Cocktails.FirstOrDefault(x => x.Id == Model.Id);
+
+ if (Cocktail == null)
+ return null;
+
+ _source.Cocktails.Remove(Cocktail);
+ _source.SaveCocktails();
+
+ return Cocktail.GetViewModel;
+ }
+ }
+}
diff --git a/Bar/BarFileImplement/BarFileImplement/Implements/ComponentStorage.cs b/Bar/BarFileImplement/BarFileImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..77b4730
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,82 @@
+using BarContracts.BindingModels;
+using BarContracts.SearchModels;
+using BarContracts.StoragesContracts;
+using BarContracts.ViewModels;
+using BarFileImplement.Models;
+
+namespace BarFileImplement.Implements
+{
+ public class ComponentStorage : IComponentStorage
+ {
+ private readonly DataFileSingleton _source;
+
+ public ComponentStorage()
+ {
+ _source = DataFileSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ return _source.Components.Select(x => x.GetViewModel).ToList();
+ }
+
+ public List GetFilteredList(ComponentSearchModel Model)
+ {
+ if (string.IsNullOrEmpty(Model.ComponentName))
+ return new();
+
+ return _source.Components.Where(x => x.ComponentName.Contains(Model.ComponentName)).Select(x => x.GetViewModel).ToList();
+ }
+
+ public ComponentViewModel? GetElement(ComponentSearchModel Model)
+ {
+ if (string.IsNullOrEmpty(Model.ComponentName) && !Model.Id.HasValue)
+ return null;
+
+ return _source.Components.FirstOrDefault(x =>
+ (!string.IsNullOrEmpty(Model.ComponentName) && x.ComponentName == Model.ComponentName) ||
+ (Model.Id.HasValue && x.Id == Model.Id))?.GetViewModel;
+ }
+
+ public ComponentViewModel? Insert(ComponentBindingModel Model)
+ {
+ Model.Id = _source.Components.Count > 0 ? _source.Components.Max(x => x.Id) + 1 : 1;
+
+ var NewComponent = Component.Create(Model);
+
+ if (NewComponent == null)
+ return null;
+
+ _source.Components.Add(NewComponent);
+ _source.SaveComponents();
+
+ return NewComponent.GetViewModel;
+ }
+
+ public ComponentViewModel? Update(ComponentBindingModel Model)
+ {
+ var Component = _source.Components.FirstOrDefault(x => x.Id == Model.Id);
+
+ if (Component == null)
+ return null;
+
+ Component.Update(Model);
+ _source.SaveComponents();
+
+ return Component.GetViewModel;
+ }
+
+ public ComponentViewModel? Delete(ComponentBindingModel Model)
+ {
+ var Component = _source.Components.FirstOrDefault(x => x.Id == Model.Id);
+
+ if (Component == null)
+ return null;
+
+ _source.Components.Remove(Component);
+ _source.SaveComponents();
+
+ return Component.GetViewModel;
+ }
+ }
+}
diff --git a/Bar/BarFileImplement/BarFileImplement/Implements/OrderStorage.cs b/Bar/BarFileImplement/BarFileImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..11ea1a9
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/Implements/OrderStorage.cs
@@ -0,0 +1,95 @@
+using BarContracts.BindingModels;
+using BarContracts.SearchModels;
+using BarContracts.StoragesContracts;
+using BarContracts.ViewModels;
+using BarFileImplement.Models;
+
+namespace BarFileImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataFileSingleton _source;
+
+ public OrderStorage()
+ {
+ _source = DataFileSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ return _source.Orders.Select(x => AddCocktailName(x.GetViewModel)).ToList();
+ }
+
+ public List GetFilteredList(OrderSearchModel Model)
+ {
+ if (!Model.Id.HasValue)
+ return new();
+
+ return _source.Orders.Where(x => x.Id == Model.Id).Select(x => AddCocktailName(x.GetViewModel)).ToList();
+ }
+
+ public OrderViewModel? Delete(OrderBindingModel Model)
+ {
+ var Element = _source.Orders.FirstOrDefault(x => x.Id == Model.Id);
+
+ if (Element != null)
+ {
+ _source.Orders.Remove(Element);
+ _source.SaveOrders();
+
+ return AddCocktailName(Element.GetViewModel);
+ }
+
+ return null;
+ }
+
+ public OrderViewModel? GetElement(OrderSearchModel Model)
+ {
+ if (!Model.Id.HasValue)
+ return null;
+
+ var Order = _source.Orders.FirstOrDefault(x => (Model.Id.HasValue && x.Id == Model.Id));
+
+ if (Order == null)
+ return null;
+
+ return AddCocktailName(Order.GetViewModel);
+ }
+
+ public OrderViewModel? Insert(OrderBindingModel Model)
+ {
+ Model.Id = _source.Orders.Count > 0 ? _source.Orders.Max(x => x.Id) + 1 : 1;
+
+ var NewOrder = Order.Create(Model);
+
+ if (NewOrder == null)
+ return null;
+
+ _source.Orders.Add(NewOrder);
+ _source.SaveOrders();
+
+ return AddCocktailName(NewOrder.GetViewModel);
+ }
+
+ public OrderViewModel? Update(OrderBindingModel Model)
+ {
+ var Order = _source.Orders.FirstOrDefault(x => x.Id == Model.Id);
+
+ if (Order == null)
+ return null;
+
+ Order.Update(Model);
+ _source.SaveOrders();
+
+ return AddCocktailName(Order.GetViewModel);
+ }
+
+ private OrderViewModel AddCocktailName(OrderViewModel Model)
+ {
+ var SelectedCocktail = _source.Cocktails.FirstOrDefault(x => x.Id == Model.CocktailId);
+
+ Model.CocktailName = SelectedCocktail?.CocktailName ?? string.Empty;
+ return Model;
+ }
+ }
+}
diff --git a/Bar/BarFileImplement/BarFileImplement/Models/Cocktail.cs b/Bar/BarFileImplement/BarFileImplement/Models/Cocktail.cs
new file mode 100644
index 0000000..8a04859
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/Models/Cocktail.cs
@@ -0,0 +1,90 @@
+using BarContracts.BindingModels;
+using BarContracts.ViewModels;
+using BarDataModels.Models;
+using System.Xml.Linq;
+
+namespace BarFileImplement.Models
+{
+ public class Cocktail : ICocktailModel
+ {
+ public int Id { get; private set; }
+
+ public string CocktailName { get; private set; } = string.Empty;
+
+ public double Price { get; private set; }
+
+ public Dictionary Components { get; private set; } = new();
+
+ private Dictionary? _CocktailComponents = null;
+
+ public Dictionary CocktailComponents
+ {
+ get
+ {
+ if (_CocktailComponents == null)
+ {
+ var source = DataFileSingleton.GetInstance();
+ _CocktailComponents = Components.ToDictionary(x =>
+ x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
+ }
+ return _CocktailComponents;
+ }
+ }
+
+ public static Cocktail? Create(CocktailBindingModel Model)
+ {
+ if (Model is null)
+ return null;
+
+ return new Cocktail()
+ {
+ Id = Model.Id,
+ CocktailName = Model.CocktailName,
+ Price = Model.Price,
+ Components = Model.CocktailComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
+ };
+ }
+ public static Cocktail? Create(XElement Element)
+ {
+ if (Element is null)
+ return null;
+
+ return new Cocktail()
+ {
+ Id = Convert.ToInt32(Element.Attribute("Id")!.Value),
+ CocktailName = Element.Element("CocktailName")!.Value,
+ Price = Convert.ToDouble(Element.Element("Price")!.Value),
+ Components = Element.Element("CocktailComponents")!.Elements("CocktailComponent").ToDictionary(x =>
+ Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
+ };
+ }
+
+ public void Update(CocktailBindingModel Model)
+ {
+ if (Model is null)
+ return;
+
+ CocktailName = Model.CocktailName;
+ Price = Model.Price;
+ Components = Model.CocktailComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
+ _CocktailComponents = null;
+ }
+
+ public CocktailViewModel GetViewModel => new()
+ {
+ Id = Id,
+ CocktailName = CocktailName,
+ Price = Price,
+ CocktailComponents = CocktailComponents
+ };
+
+ public XElement GetXElement => new(
+ "Cocktail",
+ new XAttribute("Id", Id),
+ new XElement("CocktailName", CocktailName),
+ new XElement("Price", Price.ToString()),
+ new XElement("CocktailComponents", Components.Select(x =>
+ new XElement("CocktailComponent", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray())
+ );
+ }
+}
diff --git a/Bar/BarFileImplement/BarFileImplement/Models/Component.cs b/Bar/BarFileImplement/BarFileImplement/Models/Component.cs
new file mode 100644
index 0000000..6802e4b
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/Models/Component.cs
@@ -0,0 +1,65 @@
+using BarContracts.BindingModels;
+using BarContracts.ViewModels;
+using BarDataModels.Models;
+using System.Xml.Linq;
+
+namespace BarFileImplement.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/Bar/BarFileImplement/BarFileImplement/Models/Order.cs b/Bar/BarFileImplement/BarFileImplement/Models/Order.cs
new file mode 100644
index 0000000..a74e820
--- /dev/null
+++ b/Bar/BarFileImplement/BarFileImplement/Models/Order.cs
@@ -0,0 +1,90 @@
+using BarContracts.BindingModels;
+using BarContracts.ViewModels;
+using BarDataModels.Enums;
+using BarDataModels.Models;
+using System.Xml.Linq;
+
+namespace BarFileImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+
+ public int CocktailId { 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,
+ CocktailId = Model.CocktailId,
+ 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),
+ CocktailId = Convert.ToInt32(Element.Element("CocktailId")!.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,
+ CocktailId = CocktailId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+
+ public XElement GetXElement => new(
+ "Order",
+ new XAttribute("Id", Id),
+ new XElement("CocktailId", CocktailId),
+ 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())
+ );
+ }
+}