From c840d50df7733a1e76aa0ddc957afb0dde8e27f6 Mon Sep 17 00:00:00 2001 From: "[USERNAME]" Date: Thu, 8 Feb 2024 01:19:18 +0400 Subject: [PATCH] Lab1 - start --- MotorPlant/MotorPlant.sln | 20 +++- .../MotorPlantBusinessLogic/ComponentLogic.cs | 109 ++++++++++++++++++ .../MotorPlantBusinessLogic/EngineLogic.cs | 108 +++++++++++++++++ .../MotorPlantBusinessLogic.csproj | 13 +++ .../BindingModels/ComponentBindingModel.cs | 12 ++ .../BindingModels/EngineBindingModel.cs | 16 +++ .../BindingModels/OrderBindingModel.cs | 16 +++ .../IComponentLogic.cs | 16 +++ .../BusinessLogicsContracts/IEngineLogic.cs | 15 +++ .../BusinessLogicsContracts/IOrderLogic.cs | 15 +++ .../MotorPlantContracts.csproj | 13 +++ .../SearchModels/ComponentSearchModel.cs | 9 ++ .../SearchModels/EngineSearchModel.cs | 8 ++ .../SearchModels/OrderSearchModel.cs | 7 ++ .../StoragesContracts/IComponentStorage.cs | 16 +++ .../StoragesContracts/IEngineStorage.cs | 16 +++ .../StoragesContracts/IOrderStorage.cs | 16 +++ .../ViewModels/ComponentViewModel.cs | 15 +++ .../ViewModels/EngineViewModel.cs | 19 +++ .../ViewModels/OrderViewModel.cs | 26 +++++ .../MotorPlantDataModels/IComponentModel.cs | 8 ++ .../MotorPlantDataModels/IEngineModel.cs | 10 ++ MotorPlant/MotorPlantDataModels/IId.cs | 7 ++ .../MotorPlantDataModels/IOrderModel.cs | 15 +++ .../MotorPlantDataModels.csproj | 9 ++ .../MotorPlantDataModels/OrderStatus.cs | 11 ++ 26 files changed, 544 insertions(+), 1 deletion(-) create mode 100644 MotorPlant/MotorPlantBusinessLogic/ComponentLogic.cs create mode 100644 MotorPlant/MotorPlantBusinessLogic/EngineLogic.cs create mode 100644 MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj create mode 100644 MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs create mode 100644 MotorPlant/MotorPlantContracts/BindingModels/EngineBindingModel.cs create mode 100644 MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs create mode 100644 MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IEngineLogic.cs create mode 100644 MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj create mode 100644 MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs create mode 100644 MotorPlant/MotorPlantContracts/SearchModels/EngineSearchModel.cs create mode 100644 MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs create mode 100644 MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs create mode 100644 MotorPlant/MotorPlantContracts/StoragesContracts/IEngineStorage.cs create mode 100644 MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs create mode 100644 MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs create mode 100644 MotorPlant/MotorPlantContracts/ViewModels/EngineViewModel.cs create mode 100644 MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/IComponentModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/IEngineModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/IId.cs create mode 100644 MotorPlant/MotorPlantDataModels/IOrderModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj create mode 100644 MotorPlant/MotorPlantDataModels/OrderStatus.cs diff --git a/MotorPlant/MotorPlant.sln b/MotorPlant/MotorPlant.sln index 44b3c5b..d87cb0c 100644 --- a/MotorPlant/MotorPlant.sln +++ b/MotorPlant/MotorPlant.sln @@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34031.279 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantView", "MotorPlantView\MotorPlantView.csproj", "{CEF9F4E9-71DB-4076-B8D5-3E27B49939BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MotorPlantView", "MotorPlantView\MotorPlantView.csproj", "{CEF9F4E9-71DB-4076-B8D5-3E27B49939BE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantDataModels", "MotorPlantDataModels\MotorPlantDataModels.csproj", "{4D502066-1BDE-4B18-9E3E-7FDBEF2540F1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantContracts", "MotorPlantContracts\MotorPlantContracts.csproj", "{1017E6F5-EB0E-41FC-8F8B-2E166CA6AF18}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantBusinessLogic", "MotorPlantBusinessLogic\MotorPlantBusinessLogic.csproj", "{EEA707BB-A528-4FC9-866B-5E82B3E5A881}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +21,18 @@ Global {CEF9F4E9-71DB-4076-B8D5-3E27B49939BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {CEF9F4E9-71DB-4076-B8D5-3E27B49939BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {CEF9F4E9-71DB-4076-B8D5-3E27B49939BE}.Release|Any CPU.Build.0 = Release|Any CPU + {4D502066-1BDE-4B18-9E3E-7FDBEF2540F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D502066-1BDE-4B18-9E3E-7FDBEF2540F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D502066-1BDE-4B18-9E3E-7FDBEF2540F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D502066-1BDE-4B18-9E3E-7FDBEF2540F1}.Release|Any CPU.Build.0 = Release|Any CPU + {1017E6F5-EB0E-41FC-8F8B-2E166CA6AF18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1017E6F5-EB0E-41FC-8F8B-2E166CA6AF18}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1017E6F5-EB0E-41FC-8F8B-2E166CA6AF18}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1017E6F5-EB0E-41FC-8F8B-2E166CA6AF18}.Release|Any CPU.Build.0 = Release|Any CPU + {EEA707BB-A528-4FC9-866B-5E82B3E5A881}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EEA707BB-A528-4FC9-866B-5E82B3E5A881}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EEA707BB-A528-4FC9-866B-5E82B3E5A881}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EEA707BB-A528-4FC9-866B-5E82B3E5A881}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MotorPlant/MotorPlantBusinessLogic/ComponentLogic.cs b/MotorPlant/MotorPlantBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..ffef92d --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/ComponentLogic.cs @@ -0,0 +1,109 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.BusinessLogicsContracts; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.StoragesContracts; +using MotorPlantContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace MotorPlantBusinessLogic.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("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/MotorPlant/MotorPlantBusinessLogic/EngineLogic.cs b/MotorPlant/MotorPlantBusinessLogic/EngineLogic.cs new file mode 100644 index 0000000..4100eeb --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/EngineLogic.cs @@ -0,0 +1,108 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.BusinessLogicsContracts; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.StoragesContracts; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantBusinessLogic.BusinessLogics +{ + public class EngineLogic : IEngineLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public EngineLogic(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/MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj b/MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj new file mode 100644 index 0000000..5b21394 --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..13b3cec --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,12 @@ +using MotorPlantDataModels.Models; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/BindingModels/EngineBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/EngineBindingModel.cs new file mode 100644 index 0000000..d1de6b0 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/EngineBindingModel.cs @@ -0,0 +1,16 @@ +using MotorPlantDataModels.Models; + +namespace MotorPlantContracts.BindingModels +{ + public class EngineBindingModel : IEngineModel + { + public int Id { get; set; } + public string EngineName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary EngineComponents + { + get; + set; + } = new(); + } +} diff --git a/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..b3701b9 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,16 @@ +using MotorPlantDataModels.Enums; +using MotorPlantDataModels.Models; + +namespace MotorPlantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int EngineId { 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/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..d1e96b2 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,16 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IEngineLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IEngineLogic.cs new file mode 100644 index 0000000..12302d5 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IEngineLogic.cs @@ -0,0 +1,15 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.BusinessLogicsContracts +{ + public interface IEngineLogic + { + List? ReadList(EngineSearchModel? model); + EngineViewModel? ReadElement(EngineSearchModel model); + bool Create(EngineBindingModel model); + bool Update(EngineBindingModel model); + bool Delete(EngineBindingModel model); + } +} diff --git a/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..ca3f8b3 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj b/MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj new file mode 100644 index 0000000..3fdb632 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..50c36aa --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,9 @@ +namespace MotorPlantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } + +} diff --git a/MotorPlant/MotorPlantContracts/SearchModels/EngineSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/EngineSearchModel.cs new file mode 100644 index 0000000..ee74183 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/EngineSearchModel.cs @@ -0,0 +1,8 @@ +namespace MotorPlantContracts.SearchModels +{ + public class EngineSearchModel + { + public int? Id { get; set; } + public string? EngineName { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..2255ebd --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace MotorPlantContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..c0ecfb7 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,16 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/StoragesContracts/IEngineStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IEngineStorage.cs new file mode 100644 index 0000000..08c1e2e --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IEngineStorage.cs @@ -0,0 +1,16 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.StoragesContracts +{ + public interface IEngineStorage + { + List GetFullList(); + List GetFilteredList(EngineSearchModel model); + EngineViewModel? GetElement(EngineSearchModel model); + EngineViewModel? Insert(EngineBindingModel model); + EngineViewModel? Update(EngineBindingModel model); + EngineViewModel? Delete(EngineBindingModel model); + } +} diff --git a/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..4815307 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,16 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..acac773 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,15 @@ +using MotorPlantDataModels.Models; +using System.ComponentModel; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/ViewModels/EngineViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/EngineViewModel.cs new file mode 100644 index 0000000..35c6a94 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/EngineViewModel.cs @@ -0,0 +1,19 @@ +using MotorPlantDataModels.Models; +using System.ComponentModel; + +namespace MotorPlantContracts.ViewModels +{ + public class EngineViewModel : IEngineModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string EngineName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary EngineComponents + { + get; + set; + } = new(); + } +} diff --git a/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..8481db5 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,26 @@ +using MotorPlantDataModels.Enums; +using MotorPlantDataModels.Models; +using System.ComponentModel; + +namespace MotorPlantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int EngineId { get; set; } + [DisplayName("Изделие")] + public string EngineName { 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/MotorPlant/MotorPlantDataModels/IComponentModel.cs b/MotorPlant/MotorPlantDataModels/IComponentModel.cs new file mode 100644 index 0000000..7239b56 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/IComponentModel.cs @@ -0,0 +1,8 @@ +namespace MotorPlantDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/IEngineModel.cs b/MotorPlant/MotorPlantDataModels/IEngineModel.cs new file mode 100644 index 0000000..fca257b --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/IEngineModel.cs @@ -0,0 +1,10 @@ +namespace MotorPlantDataModels.Models +{ + public interface IEngineModel : IId + { + string EngineName { get; } + double Price { get; } + Dictionary EngineComponents { get; } + } + +} diff --git a/MotorPlant/MotorPlantDataModels/IId.cs b/MotorPlant/MotorPlantDataModels/IId.cs new file mode 100644 index 0000000..d105c90 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace MotorPlantDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/IOrderModel.cs b/MotorPlant/MotorPlantDataModels/IOrderModel.cs new file mode 100644 index 0000000..97fcae5 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/IOrderModel.cs @@ -0,0 +1,15 @@ +using MotorPlantDataModels.Enums; + +namespace MotorPlantDataModels.Models +{ + public interface IOrderModel : IId + { + int EngineId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } + +} diff --git a/MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj b/MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/MotorPlant/MotorPlantDataModels/OrderStatus.cs b/MotorPlant/MotorPlantDataModels/OrderStatus.cs new file mode 100644 index 0000000..1a10e32 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/OrderStatus.cs @@ -0,0 +1,11 @@ +namespace MotorPlantDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} \ No newline at end of file