diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln index f4a799b..55a2881 100644 --- a/PrecastConcretePlant/PrecastConcretePlant.sln +++ b/PrecastConcretePlant/PrecastConcretePlant.sln @@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32901.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{F97343A9-F725-4447-BB24-6B270785836A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +21,18 @@ Global {A2739D9B-5464-45C9-AD64-93CD163EC3CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2739D9B-5464-45C9-AD64-93CD163EC3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {A2739D9B-5464-45C9-AD64-93CD163EC3CD}.Release|Any CPU.Build.0 = Release|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Release|Any CPU.Build.0 = Release|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Release|Any CPU.Build.0 = Release|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..cc7f705 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs @@ -0,0 +1,113 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace PrecastConcretePlantBusinessLogic +{ + 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/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..786a1b9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -0,0 +1,103 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Enums; + +namespace PrecastConcretePlantBusinessLogic +{ + internal class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + { + throw new ArgumentException( + $"Статус заказа должен быть {OrderStatus.Неизвестен}", nameof(model)); + } + model.Status = OrderStatus.Принят; + model.DateCreate = DateTime.Now; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется); + public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан); + public bool FinishOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Готов); + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderName.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; + } + + private bool CheckModel(OrderBindingModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum)); + } + if (model.DateCreate > model.DateImplement) + { + throw new ArgumentException("Время создания заказа не может быть больше времени его выполнения", nameof(model.DateImplement)); + } + return true; + } + + private bool SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus) + { + // Находим статус заказа по его айди + var vmodel = _orderStorage.GetElement(new() { Id = model.Id }); + if (vmodel == null) + { + throw new ArgumentNullException(nameof(model)); + } + if ((int)vmodel.Status + 1 != (int)orderStatus) + { + throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " + + $"Текущий статус: {vmodel.Status} \n" + + $"Планируемый статус: {orderStatus} \n" + + $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}", + nameof(vmodel)); + } + model.Status = orderStatus; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj new file mode 100644 index 0000000..16b4699 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs new file mode 100644 index 0000000..ae1fe4a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs @@ -0,0 +1,113 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace ConfectioneryBusinessLogic.BusinessLogics +{ + public class ReinforcedLogic : IReinforcedLogic + { + private readonly ILogger _logger; + private readonly IReinforcedStorage _componentStorage; + public ReinforcedLogic(ILogger logger, IReinforcedStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ReinforcedSearchModel? model) + { + _logger.LogInformation("ReadList. ReinforcedName:{ReinforcedName}.Id:{ Id} ", + model?.ReinforcedName, 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 ReinforcedViewModel? ReadElement(ReinforcedSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ReinforcedName:{ReinforcedName}.Id:{ Id}", + model.ReinforcedName, 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(ReinforcedBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ReinforcedBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ReinforcedBindingModel 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(ReinforcedBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ReinforcedName)) + { + throw new ArgumentNullException("Нет названия железобетонного изделия", + nameof(model.ReinforcedName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена железобетонного изделия должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Reinforced. ReinforcedName:{ReinforcedName}.Price:{ Price}. Id: { Id}", + model.ReinforcedName, model.Price, model.Id); + var element = _componentStorage.GetElement(new ReinforcedSearchModel + { + ReinforcedName = model.ReinforcedName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Железобетонное изделие с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..b21c7dc --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,12 @@ +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..522fe37 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int ReinforcedId { 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/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs new file mode 100644 index 0000000..e33afb7 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class ReinforcedBindingModel : IReinforcedModel + { + public int Id { get; set; } + public string ReinforcedName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary ReinforcedComponents + { + get; + set; + } = new(); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs new file mode 100644 index 0000000..8bf294a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs @@ -0,0 +1,15 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..93ca57c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs new file mode 100644 index 0000000..8eb560b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs @@ -0,0 +1,15 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IReinforcedLogic + { + List? ReadList(ReinforcedSearchModel? model); + ReinforcedViewModel? ReadElement(ReinforcedSearchModel model); + bool Create(ReinforcedBindingModel model); + bool Update(ReinforcedBindingModel model); + bool Delete(ReinforcedBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj new file mode 100644 index 0000000..51219ff --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..891ab27 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,8 @@ +namespace PrecastConcretePlantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..b5b956c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace PrecastConcretePlantContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs new file mode 100644 index 0000000..4d98079 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs @@ -0,0 +1,8 @@ +namespace PrecastConcretePlantContracts.SearchModels +{ + public class ReinforcedSearchModel + { + public int? Id { get; set; } + public string? ReinforcedName { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs new file mode 100644 index 0000000..a7c3042 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContract +{ + 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/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs new file mode 100644 index 0000000..30ce5fb --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContract +{ + 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/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs new file mode 100644 index 0000000..dc49554 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContract +{ + public interface IReinforcedStorage + { + List GetFullList(); + List GetFilteredList(ReinforcedSearchModel model); + ReinforcedViewModel? GetElement(ReinforcedSearchModel model); + ReinforcedViewModel? Insert(ReinforcedBindingModel model); + ReinforcedViewModel? Update(ReinforcedBindingModel model); + ReinforcedViewModel? Delete(ReinforcedBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..e010eb4 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..fe09ad6 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,31 @@ +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int ReinforcedId { get; set; } + + [DisplayName("Изделие")] + public string ReinforcedName { 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/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs new file mode 100644 index 0000000..252f6ff --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs @@ -0,0 +1,19 @@ +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class ReinforcedViewModel : IReinforcedModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string ReinforcedName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary ReinforcedComponents + { + get; + set; + } = new(); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs new file mode 100644 index 0000000..6489932 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs @@ -0,0 +1,8 @@ +namespace PrecastConcretePlantDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs new file mode 100644 index 0000000..9560ed3 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace PrecastConcretePlantDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs new file mode 100644 index 0000000..09861bc --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs @@ -0,0 +1,14 @@ +using PrecastConcretePlantDataModels.Enums; + +namespace PrecastConcretePlantDataModels.Models +{ + public interface IOrderModel : IId + { + int ReinforcedId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs new file mode 100644 index 0000000..9e99a5d --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs @@ -0,0 +1,9 @@ +namespace PrecastConcretePlantDataModels.Models +{ + public interface IReinforcedModel : IId + { + string ReinforcedName { get; } + double Price { get; } + Dictionary ReinforcedComponents { get; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs new file mode 100644 index 0000000..e3d8d41 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs @@ -0,0 +1,12 @@ +namespace PrecastConcretePlantDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + +