From def5688c0123ffebf9344e25f21ccca2a42ba50c Mon Sep 17 00:00:00 2001 From: "safiulova.k" Date: Wed, 13 Mar 2024 00:15:40 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D1=91=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AircraftPlant/AircraftPlant.sln | 16 +++- .../AircraftPlantFileImplement.csproj | 14 +++ .../AircraftPlantFileImplement/Component.cs | 59 ++++++++++++ .../ComponentStorage.cs | 78 ++++++++++++++++ .../DataFileSingleton.cs | 54 +++++++++++ .../AircraftPlantFileImplement/Order.cs | 87 ++++++++++++++++++ .../OrderStorage.cs | 87 ++++++++++++++++++ .../AircraftPlantFileImplement/Plane.cs | 92 +++++++++++++++++++ .../PlaneStorage.cs | 82 +++++++++++++++++ .../AircraftPlantView.csproj | 1 + AircraftPlant/AircraftPlantView/Program.cs | 2 +- 11 files changed, 566 insertions(+), 6 deletions(-) create mode 100644 AircraftPlant/AircraftPlantFileImplement/AircraftPlantFileImplement.csproj create mode 100644 AircraftPlant/AircraftPlantFileImplement/Component.cs create mode 100644 AircraftPlant/AircraftPlantFileImplement/ComponentStorage.cs create mode 100644 AircraftPlant/AircraftPlantFileImplement/DataFileSingleton.cs create mode 100644 AircraftPlant/AircraftPlantFileImplement/Order.cs create mode 100644 AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs create mode 100644 AircraftPlant/AircraftPlantFileImplement/Plane.cs create mode 100644 AircraftPlant/AircraftPlantFileImplement/PlaneStorage.cs diff --git a/AircraftPlant/AircraftPlant.sln b/AircraftPlant/AircraftPlant.sln index 9325f37..87d8379 100644 --- a/AircraftPlant/AircraftPlant.sln +++ b/AircraftPlant/AircraftPlant.sln @@ -3,15 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AircraftPlantView", "AircraftPlantView\AircraftPlantView.csproj", "{3D6CD163-7D74-421D-8C33-4697F3BA0808}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AircraftPlantView", "AircraftPlantView\AircraftPlantView.csproj", "{3D6CD163-7D74-421D-8C33-4697F3BA0808}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AircraftPlantDataModels", "AircraftPlantDataModels\AircraftPlantDataModels.csproj", "{6E099419-3E14-4B53-88F1-FC2A82D3D504}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AircraftPlantDataModels", "AircraftPlantDataModels\AircraftPlantDataModels.csproj", "{6E099419-3E14-4B53-88F1-FC2A82D3D504}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AircraftPlantContracts", "AircraftPlantContracts»\AircraftPlantContracts.csproj", "{C07B18D1-0947-4741-B289-07200B6CC2AC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AircraftPlantContracts", "AircraftPlantContracts»\AircraftPlantContracts.csproj", "{C07B18D1-0947-4741-B289-07200B6CC2AC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AircraftPlantBusinessLogic", "AircraftPlantBusinessLogic\AircraftPlantBusinessLogic.csproj", "{F3E5FE0D-2CAE-43D3-868E-A782D7519DE2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AircraftPlantBusinessLogic", "AircraftPlantBusinessLogic\AircraftPlantBusinessLogic.csproj", "{F3E5FE0D-2CAE-43D3-868E-A782D7519DE2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AircraftPlantListImplement", "AbstractShopListImplement\AircraftPlantListImplement.csproj", "{69BB512A-F548-45B7-B983-C3E9600CFC5D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AircraftPlantListImplement", "AbstractShopListImplement\AircraftPlantListImplement.csproj", "{69BB512A-F548-45B7-B983-C3E9600CFC5D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AircraftPlantFileImplement", "AircraftPlantFileImplement\AircraftPlantFileImplement.csproj", "{5DA728EE-42D1-45EC-A62D-67EBB0DF316C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {69BB512A-F548-45B7-B983-C3E9600CFC5D}.Debug|Any CPU.Build.0 = Debug|Any CPU {69BB512A-F548-45B7-B983-C3E9600CFC5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {69BB512A-F548-45B7-B983-C3E9600CFC5D}.Release|Any CPU.Build.0 = Release|Any CPU + {5DA728EE-42D1-45EC-A62D-67EBB0DF316C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DA728EE-42D1-45EC-A62D-67EBB0DF316C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DA728EE-42D1-45EC-A62D-67EBB0DF316C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DA728EE-42D1-45EC-A62D-67EBB0DF316C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AircraftPlant/AircraftPlantFileImplement/AircraftPlantFileImplement.csproj b/AircraftPlant/AircraftPlantFileImplement/AircraftPlantFileImplement.csproj new file mode 100644 index 0000000..a391d48 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/AircraftPlantFileImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/AircraftPlant/AircraftPlantFileImplement/Component.cs b/AircraftPlant/AircraftPlantFileImplement/Component.cs new file mode 100644 index 0000000..c993102 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/Component.cs @@ -0,0 +1,59 @@ +using AircraftPlantContracts.BindingModels; +using AircraftPlantContracts.ViewModels; +using AircraftPlantDataModels.Models; +using System.Xml.Linq; + +namespace AircraftPlantFileImplement.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/AircraftPlant/AircraftPlantFileImplement/ComponentStorage.cs b/AircraftPlant/AircraftPlantFileImplement/ComponentStorage.cs new file mode 100644 index 0000000..29e0212 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/ComponentStorage.cs @@ -0,0 +1,78 @@ +using AircraftPlantContracts.BindingModels; +using AircraftPlantContracts.StoragesContracts; +using AircraftPlantContracts.ViewModels; +using AircraftPlantContracts.SearchModels; +using AircraftPlantFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftPlantFileImplement.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 element = source.Components.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + source.Components.Remove(element); + source.SaveComponents(); + return element.GetViewModel; + } + return null; + } + } +} \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantFileImplement/DataFileSingleton.cs b/AircraftPlant/AircraftPlantFileImplement/DataFileSingleton.cs new file mode 100644 index 0000000..4d2ea23 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/DataFileSingleton.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AircraftPlantFileImplement.Models; +using System.Xml.Linq; + +namespace AircraftPlantFileImplement +{ + internal class DataFileSingleton + { + private static DataFileSingleton? instance; + private readonly string ComponentFileName = "Component.xml"; + private readonly string OrderFileName = "Order.xml"; + private readonly string PlaneFileName = "Plane.xml"; + public List Components { get; private set; } + public List Orders { get; private set; } + public List Planes { 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 SavePlanes() => SaveData(Planes, PlaneFileName, "Planes", x => x.GetXElement); + public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); + private DataFileSingleton() + { + Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; + Planes = LoadData(PlaneFileName, "Plane", x => Plane.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/AircraftPlant/AircraftPlantFileImplement/Order.cs b/AircraftPlant/AircraftPlantFileImplement/Order.cs new file mode 100644 index 0000000..bc338d7 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/Order.cs @@ -0,0 +1,87 @@ +using AircraftPlantContracts.BindingModels; +using AircraftPlantContracts.ViewModels; +using AircraftPlantDataModels.Enums; +using AircraftPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace AircraftPlantFileImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int PlaneId { 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 == null) + { + return null; + } + return new Order + { + Id = model.Id, + PlaneId = model.PlaneId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + public static Order? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Order() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + PlaneId = Convert.ToInt32(element.Element("PlaneId")!.Value), + Sum = Convert.ToDouble(element.Element("Sum")!.Value), + 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) + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + + Status = model.Status; + DateImplement = model.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + PlaneId = PlaneId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + public XElement GetXElement => new("Order", + new XAttribute("Id", Id), + new XElement("PlaneId", PlaneId), + 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())); + } +} \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs b/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs new file mode 100644 index 0000000..ad52237 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs @@ -0,0 +1,87 @@ +using AircraftPlantContracts.BindingModels; +using AircraftPlantContracts.SearchModels; +using AircraftPlantContracts.StoragesContracts; +using AircraftPlantContracts.ViewModels; +using AircraftPlantFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftPlantFileImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataFileSingleton _source; + public OrderStorage() + { + _source = DataFileSingleton.GetInstance(); + } + public List GetFullList() + { + return _source.Orders.Select(x => GetViewModel(x)).ToList(); + } + public List GetFilteredList(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return new(); + } + return _source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList(); + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + return GetViewModel(_source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))); + } + 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 GetViewModel(newOrder); + } + 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 GetViewModel(order); + } + 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 GetViewModel(element); + } + return null; + } + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + var plane = _source.Planes.FirstOrDefault(x => x.Id == order.PlaneId); + if (plane != null) + { + viewModel.PlaneName = plane.PlaneName; + } + return viewModel; + } + } +} \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantFileImplement/Plane.cs b/AircraftPlant/AircraftPlantFileImplement/Plane.cs new file mode 100644 index 0000000..6bf45c0 --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/Plane.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AircraftPlantContracts.BindingModels; +using AircraftPlantContracts.ViewModels; +using AircraftPlantDataModels.Models; +using System.Xml.Linq; + +namespace AircraftPlantFileImplement.Models +{ + public class Plane : IPlaneModel + { + public int Id { get; private set; } + public string PlaneName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary Components { get; private set; } = new(); + private Dictionary? _planeComponents = + null; + public Dictionary PlaneComponents + { + get + { + if (_planeComponents == null) + { + var source = DataFileSingleton.GetInstance(); + _planeComponents = Components.ToDictionary(x => x.Key, y => + ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, + y.Value)); + } + return _planeComponents; + } + } + public static Plane? Create(PlaneBindingModel model) + { + if (model == null) + { + return null; + } + return new Plane() + { + Id = model.Id, + PlaneName = model.PlaneName, + Price = model.Price, + Components = model.PlaneComponents.ToDictionary(x => x.Key, x + => x.Value.Item2) + }; + } + public static Plane? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Plane() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + PlaneName = element.Element("PlaneName")!.Value, + Price = Convert.ToDouble(element.Element("Price")!.Value), + Components = element.Element("PlaneComponents")!.Elements("PlaneComponent").ToDictionary(x => + Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value)) + }; + } + public void Update(PlaneBindingModel model) + { + if (model == null) + { + return; + } + PlaneName = model.PlaneName; + Price = model.Price; + Components = model.PlaneComponents.ToDictionary(x => x.Key, x => x.Value.Item2); + _planeComponents = null; + } + public PlaneViewModel GetViewModel => new() + { + Id = Id, + PlaneName = PlaneName, + Price = Price, + PlaneComponents = PlaneComponents + }; + public XElement GetXElement => new("Plane", + new XAttribute("Id", Id), + new XElement("PlaneName", PlaneName), + new XElement("Price", Price.ToString()), + new XElement("PlaneComponents", Components.Select(x => + new XElement("PlaneComponent", + new XElement("Key", x.Key), + new XElement("Value", x.Value))).ToArray())); + } +} \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantFileImplement/PlaneStorage.cs b/AircraftPlant/AircraftPlantFileImplement/PlaneStorage.cs new file mode 100644 index 0000000..dc7b31f --- /dev/null +++ b/AircraftPlant/AircraftPlantFileImplement/PlaneStorage.cs @@ -0,0 +1,82 @@ +using AircraftPlantContracts.BindingModels; +using AircraftPlantContracts.SearchModels; +using AircraftPlantContracts.StoragesContracts; +using AircraftPlantContracts.ViewModels; +using AircraftPlantFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftPlantFileImplement.Implements +{ + public class PlaneStorage : IPlaneStorage + { + private readonly DataFileSingleton _source; + public PlaneStorage() + { + _source = DataFileSingleton.GetInstance(); + } + public List GetFullList() + { + return _source.Planes.Select(x => x.GetViewModel).ToList(); + } + public List GetFilteredList(PlaneSearchModel model) + { + if (string.IsNullOrEmpty(model.PlaneName)) + { + return new(); + } + return _source.Planes.Where(x => x.PlaneName.Contains(model.PlaneName)).Select(x => x.GetViewModel).ToList(); + } + public PlaneViewModel? GetElement(PlaneSearchModel model) + { + if (string.IsNullOrEmpty(model.PlaneName) && !model.Id.HasValue) + { + return null; + } + return _source.Planes.FirstOrDefault(x => + (!string.IsNullOrEmpty(model.PlaneName) && x.PlaneName == model.PlaneName) || + (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel; + } + public PlaneViewModel? Insert(PlaneBindingModel model) + { + model.Id = _source.Planes.Count > 0 ? _source.Planes.Max(x => x.Id) + 1 : 1; + + var newPlane = Plane.Create(model); + if (newPlane == null) + { + return null; + } + + _source.Planes.Add(newPlane); + _source.SavePlanes(); + return newPlane.GetViewModel; + } + public PlaneViewModel? Update(PlaneBindingModel model) + { + var plane = _source.Planes.FirstOrDefault(x => x.Id == model.Id); + if (plane == null) + { + return null; + } + + plane.Update(model); + _source.SavePlanes(); + return plane.GetViewModel; + } + public PlaneViewModel? Delete(PlaneBindingModel model) + { + var element = _source.Planes.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + _source.Planes.Remove(element); + _source.SavePlanes(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/AircraftPlant/AircraftPlantView/AircraftPlantView.csproj b/AircraftPlant/AircraftPlantView/AircraftPlantView.csproj index 086144d..25d874a 100644 --- a/AircraftPlant/AircraftPlantView/AircraftPlantView.csproj +++ b/AircraftPlant/AircraftPlantView/AircraftPlantView.csproj @@ -17,6 +17,7 @@ + \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantView/Program.cs b/AircraftPlant/AircraftPlantView/Program.cs index 90280e1..fbdda4e 100644 --- a/AircraftPlant/AircraftPlantView/Program.cs +++ b/AircraftPlant/AircraftPlantView/Program.cs @@ -1,7 +1,7 @@ using AircraftPlantBusinessLogic.BusinessLogics; using AircraftPlantContracts.BusinessLogicsContracts; using AircraftPlantContracts.StoragesContracts; -using AircraftPlantListImplement.Implements; +using AircraftPlantFileImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -- 2.25.1 From a664753a21d8b50e297fffcb91ff4319c0403f65 Mon Sep 17 00:00:00 2001 From: "safiulova.k" Date: Sun, 24 Mar 2024 23:55:24 +0400 Subject: [PATCH 2/2] lab2 --- AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs b/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs index ad52237..ca152f7 100644 --- a/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs +++ b/AircraftPlant/AircraftPlantFileImplement/OrderStorage.cs @@ -77,10 +77,7 @@ namespace AircraftPlantFileImplement.Implements { var viewModel = order.GetViewModel; var plane = _source.Planes.FirstOrDefault(x => x.Id == order.PlaneId); - if (plane != null) - { - viewModel.PlaneName = plane.PlaneName; - } + viewModel.PlaneName = plane?.PlaneName; return viewModel; } } -- 2.25.1