diff --git a/AutomobilePlant/AutomobilePlant.sln b/AutomobilePlant/AutomobilePlant.sln
index d631254..b1eee1b 100644
--- a/AutomobilePlant/AutomobilePlant.sln
+++ b/AutomobilePlant/AutomobilePlant.sln
@@ -5,6 +5,14 @@ VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantView", "AutomobilePlantView\AutomobilePlantView.csproj", "{090C8696-D089-4462-8EE9-0C8A0CA5BD3B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantDataModels", "AutomobilePlantDataModels\AutomobilePlantDataModels.csproj", "{1E106BB0-3F72-4FB5-AF34-D8823FA89AEE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantContracts", "AutomobilePlantContracts\AutomobilePlantContracts.csproj", "{6EE45F8D-8373-446F-9269-4CB68CD4B27B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantBusinessLogic", "AutomobilePlantBusinessLogic\AutomobilePlantBusinessLogic.csproj", "{A435700B-34D0-4E80-9C8C-EA6848EBE806}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantListImplement", "AutomobilePlantListImplement\AutomobilePlantListImplement.csproj", "{930FF252-E97A-4634-A772-E07684AA6091}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +23,22 @@ Global
{090C8696-D089-4462-8EE9-0C8A0CA5BD3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{090C8696-D089-4462-8EE9-0C8A0CA5BD3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{090C8696-D089-4462-8EE9-0C8A0CA5BD3B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1E106BB0-3F72-4FB5-AF34-D8823FA89AEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1E106BB0-3F72-4FB5-AF34-D8823FA89AEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1E106BB0-3F72-4FB5-AF34-D8823FA89AEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1E106BB0-3F72-4FB5-AF34-D8823FA89AEE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6EE45F8D-8373-446F-9269-4CB68CD4B27B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6EE45F8D-8373-446F-9269-4CB68CD4B27B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6EE45F8D-8373-446F-9269-4CB68CD4B27B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6EE45F8D-8373-446F-9269-4CB68CD4B27B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A435700B-34D0-4E80-9C8C-EA6848EBE806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A435700B-34D0-4E80-9C8C-EA6848EBE806}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A435700B-34D0-4E80-9C8C-EA6848EBE806}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A435700B-34D0-4E80-9C8C-EA6848EBE806}.Release|Any CPU.Build.0 = Release|Any CPU
+ {930FF252-E97A-4634-A772-E07684AA6091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {930FF252-E97A-4634-A772-E07684AA6091}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {930FF252-E97A-4634-A772-E07684AA6091}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {930FF252-E97A-4634-A772-E07684AA6091}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/AutomobilePlant/AutomobilePlantBusinessLogic/AutomobilePlantBusinessLogic.csproj b/AutomobilePlant/AutomobilePlantBusinessLogic/AutomobilePlantBusinessLogic.csproj
new file mode 100644
index 0000000..dae74de
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantBusinessLogic/AutomobilePlantBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/CarLogic.cs b/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/CarLogic.cs
new file mode 100644
index 0000000..0832d67
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/CarLogic.cs
@@ -0,0 +1,120 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicsContracts;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StoragesContracts;
+using AutomobilePlantContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantBusinessLogic.BusinessLogics
+{
+ public class CarLogic : ICarLogic
+ {
+ private readonly ILogger _logger;
+
+ private readonly ICarStorage _carStorage;
+
+ public CarLogic(ILogger logger, ICarStorage carStorage)
+ {
+ _logger = logger;
+ _carStorage = carStorage;
+ }
+
+ public List? ReadList(CarSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. CarName:{CarName}. Id:{Id}", model?.CarName, model?.Id);
+ var list = model == null ? _carStorage.GetFullList() : _carStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public CarViewModel? ReadElement(CarSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. CarName:{CarName}. Id:{Id}", model.CarName, model.Id);
+ var element = _carStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+
+ public bool Create(CarBindingModel model)
+ {
+ CheckModel(model);
+ if (_carStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Update(CarBindingModel model)
+ {
+ CheckModel(model);
+ if (_carStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Delete(CarBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_carStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(CarBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.CarName))
+ {
+ throw new ArgumentNullException("Нет названия машины", nameof(model.CarName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена машины должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Car. CarName:{CarName}. Price:{Price}. Id:{Id}", model.CarName, model.Price, model.Id);
+ var element = _carStorage.GetElement(new CarSearchModel
+ {
+ CarName = model.CarName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Машина с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/ComponentLogic.cs b/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..c259f98
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,113 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicsContracts;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StoragesContracts;
+using AutomobilePlantContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantBusinessLogic.BusinessLogics
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentStorage _componentStorage;
+ public ComponentLogic(ILogger logger, IComponentStorage componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+ public List? ReadList(ComponentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
+ var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
+ var element = _componentStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ComponentBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+
+}
diff --git a/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs b/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..215cdf4
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,124 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicsContracts;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StoragesContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен) return false;
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
+ {
+ CheckModel(model, false);
+ var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (element == null)
+ {
+ _logger.LogWarning("Read operation failed");
+ return false;
+ }
+ if (element.Status != status - 1)
+ {
+ _logger.LogWarning("Status change operation failed");
+ throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
+ }
+ OrderStatus oldStatus = model.Status;
+ model.Status = status;
+ if (model.Status == OrderStatus.Выдан)
+ model.DateImplement = DateTime.Now;
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status = oldStatus;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выполняется);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Готов);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выдан);
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.CarId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор машин", nameof(model.CarId));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество машин в заказе должно быть больше 0", nameof(model.Count));
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count));
+ }
+ _logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id);
+ }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/AutomobilePlantContracts.csproj b/AutomobilePlant/AutomobilePlantContracts/AutomobilePlantContracts.csproj
new file mode 100644
index 0000000..743e9bf
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/AutomobilePlantContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/AutomobilePlant/AutomobilePlantContracts/BindingModels/CarBindingModel.cs b/AutomobilePlant/AutomobilePlantContracts/BindingModels/CarBindingModel.cs
new file mode 100644
index 0000000..fbcc1f6
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/BindingModels/CarBindingModel.cs
@@ -0,0 +1,22 @@
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BindingModels
+{
+ public class CarBindingModel : ICarModel
+ {
+ public int Id { get; set; }
+ public string CarName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary CarComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/BindingModels/ComponentBindingModel.cs b/AutomobilePlant/AutomobilePlantContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..027d13c
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,16 @@
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BindingModels
+{
+ public class ComponentBindingModel : IComponentModel
+ {
+ public int Id { get; set; }
+ public string ComponentName { get; set; } = string.Empty;
+ public double Cost { get; set; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs b/AutomobilePlant/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..a0e90ae
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,21 @@
+using AutomobilePlantDataModels.Enums;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int CarId { get; set; }
+ public int Count { get; set; }
+ public double Sum { get; set; }
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+ public DateTime? DateImplement { get; set; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/ICarLogic.cs b/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/ICarLogic.cs
new file mode 100644
index 0000000..64c83da
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/ICarLogic.cs
@@ -0,0 +1,20 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BusinessLogicsContracts
+{
+ public interface ICarLogic
+ {
+ List? ReadList(CarSearchModel? model);
+ CarViewModel? ReadElement(CarSearchModel model);
+ bool Create(CarBindingModel model);
+ bool Update(CarBindingModel model);
+ bool Delete(CarBindingModel model);
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/IComponentLogic.cs b/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..83d30f5
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,20 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BusinessLogicsContracts
+{
+ public interface IComponentLogic
+ {
+ List? ReadList(ComponentSearchModel? model);
+ ComponentViewModel? ReadElement(ComponentSearchModel model);
+ bool Create(ComponentBindingModel model);
+ bool Update(ComponentBindingModel model);
+ bool Delete(ComponentBindingModel model);
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..b2d87f2
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,20 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BusinessLogicsContracts
+{
+ public interface IOrderLogic
+ {
+ List? ReadList(OrderSearchModel? model);
+ bool CreateOrder(OrderBindingModel model);
+ bool TakeOrderInWork(OrderBindingModel model);
+ bool FinishOrder(OrderBindingModel model);
+ bool DeliveryOrder(OrderBindingModel model);
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/SearchModels/CarSearchModel.cs b/AutomobilePlant/AutomobilePlantContracts/SearchModels/CarSearchModel.cs
new file mode 100644
index 0000000..8994576
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/SearchModels/CarSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.SearchModels
+{
+ public class CarSearchModel
+ {
+ public int? Id { get; set; }
+ public string? CarName { get; set; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/SearchModels/ComponentSearchModel.cs b/AutomobilePlant/AutomobilePlantContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..dc2354b
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs b/AutomobilePlant/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..afbc5f1
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/ICarStorage.cs b/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/ICarStorage.cs
new file mode 100644
index 0000000..5d80368
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/ICarStorage.cs
@@ -0,0 +1,21 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.StoragesContracts
+{
+ public interface ICarStorage
+ {
+ List GetFullList();
+ List GetFilteredList(CarSearchModel model);
+ CarViewModel? GetElement(CarSearchModel model);
+ CarViewModel? Insert(CarBindingModel model);
+ CarViewModel? Update(CarBindingModel model);
+ CarViewModel? Delete(CarBindingModel model);
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/IComponentStorage.cs b/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..0a75e37
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.StoragesContracts
+{
+ public interface IComponentStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ComponentSearchModel model);
+ ComponentViewModel? GetElement(ComponentSearchModel model);
+ ComponentViewModel? Insert(ComponentBindingModel model);
+ ComponentViewModel? Update(ComponentBindingModel model);
+ ComponentViewModel? Delete(ComponentBindingModel model);
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/IOrderStorage.cs b/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..609219d
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,22 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.StoragesContracts
+{
+ public interface IOrderStorage
+ {
+ List GetFullList();
+ List GetFilteredList(OrderSearchModel model);
+ OrderViewModel? GetElement(OrderSearchModel model);
+ OrderViewModel? Insert(OrderBindingModel model);
+ OrderViewModel? Update(OrderBindingModel model);
+ OrderViewModel? Delete(OrderBindingModel model);
+ }
+
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/ViewModels/CarViewModel.cs b/AutomobilePlant/AutomobilePlantContracts/ViewModels/CarViewModel.cs
new file mode 100644
index 0000000..8b947f3
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/ViewModels/CarViewModel.cs
@@ -0,0 +1,25 @@
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.ViewModels
+{
+ public class CarViewModel : ICarModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string CarName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary CarComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/ViewModels/ComponentViewModel.cs b/AutomobilePlant/AutomobilePlantContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..92d581d
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,19 @@
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.ViewModels
+{
+ public class ComponentViewModel : IComponentModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название компонента")]
+ public string ComponentName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Cost { get; set; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantContracts/ViewModels/OrderViewModel.cs b/AutomobilePlant/AutomobilePlantContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..06dcbe1
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,30 @@
+using AutomobilePlantDataModels.Enums;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int CarId { get; set; }
+ [DisplayName("Изделие")]
+ public string CarName { get; set; } = string.Empty;
+ [DisplayName("Количество")]
+ public int Count { get; set; }
+ [DisplayName("Сумма")]
+ public double Sum { get; set; }
+ [DisplayName("Статус")]
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+ [DisplayName("Дата выполнения")]
+ public DateTime? DateImplement { get; set; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantDataModels/AutomobilePlantDataModels.csproj b/AutomobilePlant/AutomobilePlantDataModels/AutomobilePlantDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantDataModels/AutomobilePlantDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/AutomobilePlant/AutomobilePlantDataModels/Enums/OrderStatus.cs b/AutomobilePlant/AutomobilePlantDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..b257d0e
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantDataModels/IId.cs b/AutomobilePlant/AutomobilePlantDataModels/IId.cs
new file mode 100644
index 0000000..1dd266c
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantDataModels/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantDataModels/Models/ICarModel.cs b/AutomobilePlant/AutomobilePlantDataModels/Models/ICarModel.cs
new file mode 100644
index 0000000..53e8864
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantDataModels/Models/ICarModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDataModels.Models
+{
+ public interface ICarModel : IId
+ {
+ string CarName { get; }
+ double Price { get; }
+ Dictionary CarComponents { get; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantDataModels/Models/IComponentModel.cs b/AutomobilePlant/AutomobilePlantDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..65039ce
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantDataModels/Models/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantDataModels/Models/IOrderModel.cs b/AutomobilePlant/AutomobilePlantDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..ee46a2c
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantDataModels/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using AutomobilePlantDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int CarId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/AutomobilePlantListImplement.csproj b/AutomobilePlant/AutomobilePlantListImplement/AutomobilePlantListImplement.csproj
new file mode 100644
index 0000000..a6820c2
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/AutomobilePlantListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/AutomobilePlant/AutomobilePlantListImplement/DataListSingleton.cs b/AutomobilePlant/AutomobilePlantListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..2406e38
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/DataListSingleton.cs
@@ -0,0 +1,31 @@
+using AutomobilePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement
+{
+ internal class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Cars { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Cars = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/Implements/CarStorage.cs b/AutomobilePlant/AutomobilePlantListImplement/Implements/CarStorage.cs
new file mode 100644
index 0000000..e54edd5
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/Implements/CarStorage.cs
@@ -0,0 +1,110 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StoragesContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement.Implements
+{
+ public class CarStorage : ICarStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public CarStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var car in _source.Cars)
+ {
+ result.Add(car.GetViewModel);
+ }
+ return result;
+ }
+
+ public List GetFilteredList(CarSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.CarName))
+ {
+ return result;
+ }
+ foreach (var car in _source.Cars)
+ {
+ if (car.CarName.Contains(model.CarName))
+ {
+ result.Add(car.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public CarViewModel? GetElement(CarSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.CarName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var car in _source.Cars)
+ {
+ if ((!string.IsNullOrEmpty(model.CarName) && car.CarName == model.CarName) || (model.Id.HasValue && car.Id == model.Id))
+ {
+ return car.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public CarViewModel? Insert(CarBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var car in _source.Cars)
+ {
+ if (model.Id <= car.Id)
+ {
+ model.Id = car.Id + 1;
+ }
+ }
+ var newCar = Car.Create(model);
+ if (newCar == null)
+ {
+ return null;
+ }
+ _source.Cars.Add(newCar);
+ return newCar.GetViewModel;
+ }
+
+ public CarViewModel? Update(CarBindingModel model)
+ {
+ foreach (var car in _source.Cars)
+ {
+ if (car.Id == model.Id)
+ {
+ car.Update(model);
+ return car.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public CarViewModel? Delete(CarBindingModel model)
+ {
+ for (int i = 0; i < _source.Cars.Count; ++i)
+ {
+ if (_source.Cars[i].Id == model.Id)
+ {
+ var element = _source.Cars[i];
+ _source.Cars.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/Implements/ComponentStorage.cs b/AutomobilePlant/AutomobilePlantListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..e30f589
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,109 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StoragesContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement.Implements
+{
+ public class ComponentStorage : IComponentStorage
+ {
+ private readonly DataListSingleton _source;
+ public ComponentStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var component in _source.Components)
+ {
+ result.Add(component.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ComponentSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Components)
+ {
+ if (component.ComponentName.Contains(model.ComponentName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public ComponentViewModel? GetElement(ComponentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var component in _source.Components)
+ {
+ if (
+ (!string.IsNullOrEmpty(model.ComponentName) &&
+ component.ComponentName == model.ComponentName) ||
+ (model.Id.HasValue && component.Id == model.Id)
+ )
+ {
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ComponentViewModel? Insert(ComponentBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var component in _source.Components)
+ {
+ if (model.Id <= component.Id)
+ {
+ model.Id = component.Id + 1;
+ }
+ }
+ var newComponent = Component.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ _source.Components.Add(newComponent);
+ return newComponent.GetViewModel;
+ }
+ public ComponentViewModel? Update(ComponentBindingModel model)
+ {
+ foreach (var component in _source.Components)
+ {
+ if (component.Id == model.Id)
+ {
+ component.Update(model);
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ComponentViewModel? Delete(ComponentBindingModel model)
+ {
+ for (int i = 0; i < _source.Components.Count; ++i)
+ {
+ if (_source.Components[i].Id == model.Id)
+ {
+ var element = _source.Components[i];
+ _source.Components.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/Implements/OrderStorage.cs b/AutomobilePlant/AutomobilePlantListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..d7091fc
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,107 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StoragesContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(order.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (!model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(order.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (
+ (model.Id.HasValue && order.Id == model.Id)
+ )
+ {
+ return order.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return newOrder.GetViewModel;
+ }
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return order.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Orders.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/Models/Car.cs b/AutomobilePlant/AutomobilePlantListImplement/Models/Car.cs
new file mode 100644
index 0000000..2f26083
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/Models/Car.cs
@@ -0,0 +1,57 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement.Models
+{
+ public class Car : ICarModel
+ {
+ public int Id { get; private set; }
+
+ public string CarName { get; private set; } = string.Empty;
+
+ public double Price { get; private set; }
+
+ public Dictionary CarComponents { get; private set; } = new Dictionary();
+
+ public static Car? Create(CarBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Car()
+ {
+ Id = model.Id,
+ CarName = model.CarName,
+ Price = model.Price,
+ CarComponents = model.CarComponents
+ };
+ }
+
+ public void Update(CarBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ CarName = model.CarName;
+ Price = model.Price;
+ CarComponents = model.CarComponents;
+ }
+
+ public CarViewModel GetViewModel => new()
+ {
+ Id = Id,
+ CarName = CarName,
+ Price = Price,
+ CarComponents = CarComponents
+ };
+ }
+
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/Models/Component.cs b/AutomobilePlant/AutomobilePlantListImplement/Models/Component.cs
new file mode 100644
index 0000000..924aae2
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/Models/Component.cs
@@ -0,0 +1,46 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement.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 void Update(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+ }
+}
diff --git a/AutomobilePlant/AutomobilePlantListImplement/Models/Order.cs b/AutomobilePlant/AutomobilePlantListImplement/Models/Order.cs
new file mode 100644
index 0000000..6250a8e
--- /dev/null
+++ b/AutomobilePlant/AutomobilePlantListImplement/Models/Order.cs
@@ -0,0 +1,73 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Enums;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int CarId { get; private set; }
+
+ public int Count { get; private set; }
+
+ public double Sum { get; private set; }
+
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+
+ public DateTime? DateImplement { get; private set; }
+
+ public int Id { get; private set; }
+
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order
+ {
+ Id = model.Id,
+ CarId = model.CarId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ };
+ }
+
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Id = model.Id;
+ CarId = model.CarId;
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateCreate = model.DateCreate;
+ DateImplement = model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ CarId = CarId,
+ Count = Count,
+ Sum = Sum,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ Id = Id,
+ Status = Status,
+ };
+ }
+}