diff --git a/MotorPlant/MotorPlant.sln b/MotorPlant/MotorPlant.sln index 0dfdc94..b25ecd4 100644 --- a/MotorPlant/MotorPlant.sln +++ b/MotorPlant/MotorPlant.sln @@ -5,6 +5,14 @@ VisualStudioVersion = 17.2.32630.192 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantView", "MotorPlantView\MotorPlantView.csproj", "{B43E5117-8411-4DC7-BEC1-733375340077}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantDataModels", "MotorPlantDataModels\MotorPlantDataModels.csproj", "{31FF3741-D7A9-403C-A4DB-05BD4E091210}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantContracts", "MotorPlantContracts\MotorPlantContracts.csproj", "{97078DD1-7E5F-4AA7-BAF7-70CD48BFC6C6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantListImplement", "MotorPlantListImplement\MotorPlantListImplement.csproj", "{801EEF71-F335-4052-9B3D-F3DD55741AEB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorPlantBusinessLogic", "MotorPlantBusinessLogic\MotorPlantBusinessLogic.csproj", "{B9A5F92C-4A61-464F-883F-6DE91C3555D9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +23,22 @@ Global {B43E5117-8411-4DC7-BEC1-733375340077}.Debug|Any CPU.Build.0 = Debug|Any CPU {B43E5117-8411-4DC7-BEC1-733375340077}.Release|Any CPU.ActiveCfg = Release|Any CPU {B43E5117-8411-4DC7-BEC1-733375340077}.Release|Any CPU.Build.0 = Release|Any CPU + {31FF3741-D7A9-403C-A4DB-05BD4E091210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31FF3741-D7A9-403C-A4DB-05BD4E091210}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31FF3741-D7A9-403C-A4DB-05BD4E091210}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31FF3741-D7A9-403C-A4DB-05BD4E091210}.Release|Any CPU.Build.0 = Release|Any CPU + {97078DD1-7E5F-4AA7-BAF7-70CD48BFC6C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97078DD1-7E5F-4AA7-BAF7-70CD48BFC6C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97078DD1-7E5F-4AA7-BAF7-70CD48BFC6C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97078DD1-7E5F-4AA7-BAF7-70CD48BFC6C6}.Release|Any CPU.Build.0 = Release|Any CPU + {801EEF71-F335-4052-9B3D-F3DD55741AEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {801EEF71-F335-4052-9B3D-F3DD55741AEB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {801EEF71-F335-4052-9B3D-F3DD55741AEB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {801EEF71-F335-4052-9B3D-F3DD55741AEB}.Release|Any CPU.Build.0 = Release|Any CPU + {B9A5F92C-4A61-464F-883F-6DE91C3555D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9A5F92C-4A61-464F-883F-6DE91C3555D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9A5F92C-4A61-464F-883F-6DE91C3555D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9A5F92C-4A61-464F-883F-6DE91C3555D9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ComponentLogic.cs b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..1070e30 --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ComponentLogic.cs @@ -0,0 +1,120 @@ +using Microsoft.Extensions.Logging; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.BusinessLogicsContracts; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.StoragesContracts; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantBusinessLogic.BusinessLogic +{ + 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/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/OrderLogic.cs b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..ba8faa7 --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/OrderLogic.cs @@ -0,0 +1,40 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.BusinessLogicsContracts; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantBusinessLogic.BusinessLogic +{ + public class OrderLogic : IOrderLogic + { + public bool CreateOrder(OrderBindingModel model) + { + throw new NotImplementedException(); + } + + public bool DeliveryOrder(OrderBindingModel model) + { + throw new NotImplementedException(); + } + + public bool FinishOrder(OrderBindingModel model) + { + throw new NotImplementedException(); + } + + public List? ReadList(OrderSearchModel? model) + { + throw new NotImplementedException(); + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ProductLogic.cs b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ProductLogic.cs new file mode 100644 index 0000000..8f8f829 --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ProductLogic.cs @@ -0,0 +1,40 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.BusinessLogicsContracts; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantBusinessLogic.BusinessLogic +{ + public class ProductLogic : IProductLogic + { + public bool Create(ProductBindingModel model) + { + throw new NotImplementedException(); + } + + public bool Delete(ProductBindingModel model) + { + throw new NotImplementedException(); + } + + public ProductViewModel? ReadElement(ProductSearchModel model) + { + throw new NotImplementedException(); + } + + public List? ReadList(ProductSearchModel? model) + { + throw new NotImplementedException(); + } + + public bool Update(ProductBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj b/MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj new file mode 100644 index 0000000..2cb6f45 --- /dev/null +++ b/MotorPlant/MotorPlantBusinessLogic/MotorPlantBusinessLogic.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..eb1dbf3 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,18 @@ +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/OrderBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..b0e59fc --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,27 @@ +using MotorPlantDataModels.Enums; +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + + public int ProductId { 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/BindingModels/ProductBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/ProductBindingModel.cs new file mode 100644 index 0000000..e470fee --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/ProductBindingModel.cs @@ -0,0 +1,20 @@ +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.BindingModels +{ + public class ProductBindingModel : IProductModel + { + public int Id { get; set; } + + public string ProductName { get; set; } = string.Empty; + + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + } +} diff --git a/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..9d53d57 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,24 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/IOrderLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..d9f0668 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,24 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/BusinessLogicsContracts/IProductLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IProductLogic.cs new file mode 100644 index 0000000..4bae22d --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IProductLogic.cs @@ -0,0 +1,24 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.BusinessLogicsContracts +{ + public interface IProductLogic + { + List? ReadList(ProductSearchModel? model); + + ProductViewModel? ReadElement(ProductSearchModel model); + + bool Create(ProductBindingModel model); + + bool Update(ProductBindingModel model); + + bool Delete(ProductBindingModel 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..0938ddc --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + + public string? ComponentName { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..227d688 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs new file mode 100644 index 0000000..0afdd1a --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.SearchModels +{ + public class ProductSearchModel + { + public int? Id { get; set; } + + public string? ProductName { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..620c28f --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,26 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/IOrderStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..903a6ab --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,26 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/StoragesContracts/IProducStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IProducStorage.cs new file mode 100644 index 0000000..2a3e296 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IProducStorage.cs @@ -0,0 +1,26 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.StoragesContracts +{ + public interface IProductStorage + { + List GetFullList(); + + List GetFilteredList(ProductSearchModel model); + + ProductViewModel? GetElement(ProductSearchModel model); + + ProductViewModel? Insert(ProductBindingModel model); + + ProductViewModel? Update(ProductBindingModel model); + + ProductViewModel? Delete(ProductBindingModel model); + } +} diff --git a/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..efa263c --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,21 @@ +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/OrderViewModels.cs b/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModels.cs new file mode 100644 index 0000000..1bf0e22 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModels.cs @@ -0,0 +1,37 @@ +using MotorPlantDataModels.Enums; +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + + public int ProductId { get; set; } + + [DisplayName("Изделие")] + public string ProductName { 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/MotorPlantContracts/ViewModels/ProductViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/ProductViewModel.cs new file mode 100644 index 0000000..4b432e4 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/ProductViewModel.cs @@ -0,0 +1,23 @@ +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.ViewModels +{ + public class ProductViewModel : IProductModel + { + public int Id { get; set; } + + [DisplayName("Название изделия")] + public string ProductName { get; set; } = string.Empty; + + [DisplayName("Цена")] + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + } +} diff --git a/MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs b/MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..3fec86a --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + + Принят = 0, + + Выполняется = 1, + + Готов = 2, + + Выдан = 3 + } +} diff --git a/MotorPlant/MotorPlantDataModels/IId.cs b/MotorPlant/MotorPlantDataModels/IId.cs new file mode 100644 index 0000000..23788c5 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs b/MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..c97d8a1 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + + double Cost { get; } + } +} \ No newline at end of file diff --git a/MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs b/MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..5b9f4f4 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs @@ -0,0 +1,24 @@ +using MotorPlantDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Models +{ + public interface IOrderModel : IId + { + int ProductId { get; } + + int Count { get; } + + double Sum { get; } + + OrderStatus Status { get; } + + DateTime DateCreate { get; } + + DateTime? DateImplement { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/Models/IProductModel.cs b/MotorPlant/MotorPlantDataModels/Models/IProductModel.cs new file mode 100644 index 0000000..401a6c5 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Models/IProductModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Models +{ + public interface IProductModel : IId + { + string ProductName { get; } + + double Price { get; } + + Dictionary ProductComponents { 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/MotorPlantListImplement/DataListSingleton.cs b/MotorPlant/MotorPlantListImplement/DataListSingleton.cs new file mode 100644 index 0000000..c424e6d --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/DataListSingleton.cs @@ -0,0 +1,37 @@ +using MotorPlantListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement +{ + internal class DataListSingleton + { + private static DataListSingleton? _instance; + + public List Components { get; set; } + + public List Orders { get; set; } + + public List Products { get; set; } + + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Products = new List(); + } + + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + + return _instance; + } + } +} diff --git a/MotorPlant/MotorPlantListImplement/Implements/ComponentStorage.cs b/MotorPlant/MotorPlantListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..349463d --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,113 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.StoragesContracts; +using MotorPlantContracts.ViewModels; +using MotorPlantListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement.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/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs b/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..cdf90fd --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs @@ -0,0 +1,45 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.StoragesContracts; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + public OrderViewModel? Delete(OrderBindingModel model) + { + throw new NotImplementedException(); + } + + public OrderViewModel? GetElement(OrderSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFilteredList(OrderSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFullList() + { + throw new NotImplementedException(); + } + + public OrderViewModel? Insert(OrderBindingModel model) + { + throw new NotImplementedException(); + } + + public OrderViewModel? Update(OrderBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/MotorPlant/MotorPlantListImplement/Implements/ProductStorage.cs b/MotorPlant/MotorPlantListImplement/Implements/ProductStorage.cs new file mode 100644 index 0000000..5046a70 --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/Implements/ProductStorage.cs @@ -0,0 +1,45 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.StoragesContracts; +using MotorPlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement.Implements +{ + public class ProductStorage : IProductStorage + { + public ProductViewModel? Delete(ProductBindingModel model) + { + throw new NotImplementedException(); + } + + public ProductViewModel? GetElement(ProductSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFilteredList(ProductSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFullList() + { + throw new NotImplementedException(); + } + + public ProductViewModel? Insert(ProductBindingModel model) + { + throw new NotImplementedException(); + } + + public ProductViewModel? Update(ProductBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/MotorPlant/MotorPlantListImplement/Models/Component.cs b/MotorPlant/MotorPlantListImplement/Models/Component.cs new file mode 100644 index 0000000..3a1a9af --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/Models/Component.cs @@ -0,0 +1,51 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.ViewModels; +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement.Models +{ + internal 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/MotorPlant/MotorPlantListImplement/Models/Order.cs b/MotorPlant/MotorPlantListImplement/Models/Order.cs new file mode 100644 index 0000000..7a8b1ae --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/Models/Order.cs @@ -0,0 +1,43 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.ViewModels; +using MotorPlantDataModels.Enums; +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement.Models +{ + internal class Order : IOrderModel + { + public int ProductId => throw new NotImplementedException(); + + public int Count => throw new NotImplementedException(); + + public double Sum => throw new NotImplementedException(); + + public OrderStatus Status => throw new NotImplementedException(); + + public DateTime DateCreate => throw new NotImplementedException(); + + public DateTime? DateImplement => throw new NotImplementedException(); + + public int Id => throw new NotImplementedException(); + + public static Order? Create(OrderBindingModel? model) + { + return new Order(); + } + + public void Update(OrderBindingModel? model) + { + + } + + public OrderViewModel GetViewModel => new() + { + }; + } +} diff --git a/MotorPlant/MotorPlantListImplement/Models/Product.cs b/MotorPlant/MotorPlantListImplement/Models/Product.cs new file mode 100644 index 0000000..7e33a43 --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/Models/Product.cs @@ -0,0 +1,56 @@ +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.ViewModels; +using MotorPlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantListImplement.Models +{ + internal class Product : IProductModel + { + public int Id { get; private set; } + + public string ProductName { get; private set; } = string.Empty; + + public double Price { get; private set; } + + public Dictionary ProductComponents { get; private set; } = new Dictionary(); + + public static Product? Create(ProductBindingModel? model) + { + if (model == null) + { + return null; + } + return new Product() + { + Id = model.Id, + ProductName = model.ProductName, + Price = model.Price, + ProductComponents = model.ProductComponents + }; + } + + public void Update(ProductBindingModel? model) + { + if (model == null) + { + return; + } + ProductName = model.ProductName; + Price = model.Price; + ProductComponents = model.ProductComponents; + } + + public ProductViewModel GetViewModel => new() + { + Id = Id, + ProductName = ProductName, + Price = Price, + ProductComponents = ProductComponents + }; + } +} diff --git a/MotorPlant/MotorPlantListImplement/MotorPlantListImplement.csproj b/MotorPlant/MotorPlantListImplement/MotorPlantListImplement.csproj new file mode 100644 index 0000000..4da00b3 --- /dev/null +++ b/MotorPlant/MotorPlantListImplement/MotorPlantListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/MotorPlant/MotorPlantView/Form1.Designer.cs b/MotorPlant/MotorPlantView/Form1.Designer.cs deleted file mode 100644 index 3955c75..0000000 --- a/MotorPlant/MotorPlantView/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace MotorPlantView -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/MotorPlant/MotorPlantView/Form1.cs b/MotorPlant/MotorPlantView/Form1.cs deleted file mode 100644 index 9ef675b..0000000 --- a/MotorPlant/MotorPlantView/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MotorPlantView -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/MotorPlant/MotorPlantView/FormComponents.Designer.cs b/MotorPlant/MotorPlantView/FormComponents.Designer.cs new file mode 100644 index 0000000..686141f --- /dev/null +++ b/MotorPlant/MotorPlantView/FormComponents.Designer.cs @@ -0,0 +1,122 @@ +namespace MotorPlantView +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(370, 132); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(75, 23); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(370, 91); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(75, 23); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(370, 50); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(75, 23); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(370, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.Size = new System.Drawing.Size(350, 312); + this.dataGridView.TabIndex = 0; + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(464, 312); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormComponents"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Компоненты"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonRef; + private System.Windows.Forms.Button buttonDel; + private System.Windows.Forms.Button buttonUpd; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/MotorPlant/MotorPlantView/FormComponents.cs b/MotorPlant/MotorPlantView/FormComponents.cs new file mode 100644 index 0000000..be1e874 --- /dev/null +++ b/MotorPlant/MotorPlantView/FormComponents.cs @@ -0,0 +1,112 @@ +using MotorPlantContracts.BindingModels; +using Microsoft.Extensions.Logging; +using MotorPlantContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace MotorPlantView +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + + private readonly IComponentLogic _logic; + + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel { Id = id })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/MotorPlant/MotorPlantView/Form1.resx b/MotorPlant/MotorPlantView/FormComponents.resx similarity index 100% rename from MotorPlant/MotorPlantView/Form1.resx rename to MotorPlant/MotorPlantView/FormComponents.resx diff --git a/MotorPlant/MotorPlantView/MotorPlantView.csproj b/MotorPlant/MotorPlantView/MotorPlantView.csproj index b57c89e..22ba433 100644 --- a/MotorPlant/MotorPlantView/MotorPlantView.csproj +++ b/MotorPlant/MotorPlantView/MotorPlantView.csproj @@ -8,4 +8,17 @@ enable + + + + + + + + + + + + + \ No newline at end of file diff --git a/MotorPlant/MotorPlantView/Program.cs b/MotorPlant/MotorPlantView/Program.cs index 2e234f5..7bc2c7e 100644 --- a/MotorPlant/MotorPlantView/Program.cs +++ b/MotorPlant/MotorPlantView/Program.cs @@ -1,17 +1,49 @@ +using Microsoft.Extensions.DependencyInjection; +using MotorPlantBusinessLogic.BusinessLogic; +using MotorPlantContracts.BusinessLogicsContracts; +using MotorPlantContracts.StoragesContracts; +using MotorPlantListImplement.Implements; + namespace MotorPlantView { - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } - } + internal static class Program + { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + // Application.Run(new Form1()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + } } \ No newline at end of file