diff --git a/CarpentryWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs b/CarpentryWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs index 07795aa..09b576b 100644 --- a/CarpentryWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/CarpentryWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -13,129 +13,124 @@ using System.Threading.Tasks; namespace CarpentryWorkshopBusinessLogic.BusinessLogics { - public class OrderLogic : IOrderLogic - { - private readonly ILogger _logger; - private readonly IOrderStorage _orderStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage) - { - _logger = logger; - _orderStorage = orderStorage; - } - public List? ReadList(OrderSearchModel? model) - { - _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); - var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); - if (list == null) - { - _logger.LogWarning("ReadList return null list"); - return null; - } - _logger.LogInformation("ReadList. Count:{Count}", list.Count); - return list; - } - public bool CreateOrder(OrderBindingModel model) - { - _orderStorage.Insert(new OrderBindingModel - { - WoodId = model.WoodId, - WoodName = model.WoodName, - Count = model.Count, - Sum = model.Sum, - Status = OrderStatus.Принят, - DateCreate = DateTime.Now - }); ; - return true; - } - public bool TakeOrderInWork(OrderBindingModel model) - { - var order = _orderStorage.GetElement(new OrderSearchModel - { - Id = model.Id - }); - if (order == null) - { - throw new Exception("Элемент не найден"); - } - if (order.Status.ToString() != "Принят") - { - throw new Exception("Заказ не в статусе \"Принят\""); - } - _orderStorage.Update(new OrderBindingModel - { - Id = order.Id, - WoodId = order.WoodId, - WoodName = order.WoodName, - Count = order.Count, - Sum = order.Sum, - DateCreate = order.DateCreate, - - Status = OrderStatus.Выполняется - }); - return true; - } - public bool FinishOrder(OrderBindingModel model) - { - var order = _orderStorage.GetElement(new OrderSearchModel - { - Id = model.Id - }); - if (order == null) - { - throw new Exception("Не найден заказ"); - } - if (order.Status.ToString() != "Выполняется") - { - throw new Exception("Заказ не в статусе \"Выполняется\""); - } - _orderStorage.Update(new OrderBindingModel - { - Id = order.Id, - WoodId = order.WoodId, - WoodName = order.WoodName, - Count = order.Count, - Sum = order.Sum, - DateCreate = order.DateCreate, - DateImplement = DateTime.Now, - Status = OrderStatus.Готов - }); - return true; - } - public bool DeliveryOrder(OrderBindingModel model) - { - var order = _orderStorage.GetElement(new OrderSearchModel - { - Id = model.Id - }); - if (order == null) - { - throw new Exception("Не найден заказ"); - } + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public bool CreateOrder(OrderBindingModel model) + { + _orderStorage.Insert(new OrderBindingModel + { + WoodId = model.WoodId, + WoodName = model.WoodName, + Count = model.Count, + Sum = model.Sum, + Status = OrderStatus.Принят, + DateCreate = DateTime.Now + }); ; + return true; + } + public bool TakeOrderInWork(OrderBindingModel model) + { + var order = _orderStorage.GetElement(new OrderSearchModel + { + Id = model.Id + }); + if (order == null) + { + throw new Exception("Элемент не найден"); + } + if (order.Status.ToString() != "Принят") + { + throw new Exception("Заказ не в статусе \"Принят\""); + } + _orderStorage.Update(new OrderBindingModel + { + Id = order.Id, + WoodId = order.WoodId, + WoodName = order.WoodName, + Count = order.Count, + Sum = order.Sum, + DateCreate = order.DateCreate, - if (order.Status.ToString() != "Готов") - { - throw new Exception("Заказ не в статусе \"Готов\""); - } + Status = OrderStatus.Выполняется + }); + return true; + } + public bool FinishOrder(OrderBindingModel model) + { + var order = _orderStorage.GetElement(new OrderSearchModel + { + Id = model.Id + }); + if (order == null) + { + throw new Exception("Не найден заказ"); + } + if (order.Status.ToString() != "Выполняется") + { + throw new Exception("Заказ не в статусе \"Выполняется\""); + } + _orderStorage.Update(new OrderBindingModel + { + Id = order.Id, + WoodId = order.WoodId, + WoodName = order.WoodName, + Count = order.Count, + Sum = order.Sum, + DateCreate = order.DateCreate, + DateImplement = DateTime.Now, + Status = OrderStatus.Готов + }); + return true; + } + public bool DeliveryOrder(OrderBindingModel model) + { + var order = _orderStorage.GetElement(new OrderSearchModel + { + Id = model.Id + }); + if (order == null) + { + throw new Exception("Не найден заказ"); + } - _orderStorage.Update(new OrderBindingModel - { - Id = order.Id, - WoodId = order.WoodId, - WoodName = order.WoodName, - Count = order.Count, - Sum = order.Sum, - DateCreate = order.DateCreate, - DateImplement = order.DateImplement, - Status = OrderStatus.Выдан - }); - return true; + if (order.Status.ToString() != "Готов") + { + throw new Exception("Заказ не в статусе \"Готов\""); + } - } + _orderStorage.Update(new OrderBindingModel + { + Id = order.Id, + WoodId = order.WoodId, + WoodName = order.WoodName, + Count = order.Count, + Sum = order.Sum, + DateCreate = order.DateCreate, + DateImplement = order.DateImplement, + Status = OrderStatus.Выдан + }); + return true; - - - - - - } + } + } } + diff --git a/CarpentryWorkshopBusinessLogic/BusinessLogics/WoodLogic.cs b/CarpentryWorkshopBusinessLogic/BusinessLogics/WoodLogic.cs index dc5b8bd..e78c8ea 100644 --- a/CarpentryWorkshopBusinessLogic/BusinessLogics/WoodLogic.cs +++ b/CarpentryWorkshopBusinessLogic/BusinessLogics/WoodLogic.cs @@ -88,11 +88,11 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics } if (string.IsNullOrEmpty(model.WoodName)) { - throw new ArgumentNullException("Нет названия компонента", nameof(model.WoodName)); + throw new ArgumentNullException("Нет названия изделия", nameof(model.WoodName)); } if (model.Price <= 0) { - throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price)); + throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); } _logger.LogInformation("Wood. WoodName:{WoodName}. Cost:{ Cost}. Id: { Id}", model.WoodName, model.Price, model.Id); var element = _woodStorage.GetElement(new WoodSearchModel @@ -101,7 +101,7 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Компонент с таким названием уже есть"); + throw new InvalidOperationException("Изделие с таким названием уже есть"); } } } diff --git a/CarpentryWorkshopBusinessLogic/Class1.cs b/CarpentryWorkshopBusinessLogic/Class1.cs deleted file mode 100644 index 41846ac..0000000 --- a/CarpentryWorkshopBusinessLogic/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CarpentryWorkshopBusinessLogic -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/CarpentryWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs b/CarpentryWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs index 99635fc..8ce823b 100644 --- a/CarpentryWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/CarpentryWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -16,6 +16,5 @@ namespace CarpentryWorkshopContracts.BusinessLogicsContracts bool TakeOrderInWork(OrderBindingModel model); bool FinishOrder(OrderBindingModel model); bool DeliveryOrder(OrderBindingModel model); - } } diff --git a/CarpentryWorkshopContracts/Class1.cs b/CarpentryWorkshopContracts/Class1.cs deleted file mode 100644 index 26e1951..0000000 --- a/CarpentryWorkshopContracts/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CarpentryWorkshopContracts -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/CarpentryWorkshopContracts/SearchModels/ComponentSearchModel.cs b/CarpentryWorkshopContracts/SearchModels/ComponentSearchModel.cs index d584872..d9e1fe0 100644 --- a/CarpentryWorkshopContracts/SearchModels/ComponentSearchModel.cs +++ b/CarpentryWorkshopContracts/SearchModels/ComponentSearchModel.cs @@ -11,5 +11,4 @@ namespace CarpentryWorkshopContracts.SearchModels public int? Id { get; set; } public string? ComponentName { get; set; } } - } diff --git a/CarpentryWorkshopContracts/SearchModels/WoodSearchModel.cs b/CarpentryWorkshopContracts/SearchModels/WoodSearchModel.cs index b5ac7bd..e1a1a65 100644 --- a/CarpentryWorkshopContracts/SearchModels/WoodSearchModel.cs +++ b/CarpentryWorkshopContracts/SearchModels/WoodSearchModel.cs @@ -11,5 +11,4 @@ namespace CarpentryWorkshopContracts.SearchModels public int? Id { get; set; } public string? WoodName { get; set; } } - } diff --git a/CarpentryWorkshopContracts/ViewModels/ComponentViewModel.cs b/CarpentryWorkshopContracts/ViewModels/ComponentViewModel.cs index 0c17489..31f15c0 100644 --- a/CarpentryWorkshopContracts/ViewModels/ComponentViewModel.cs +++ b/CarpentryWorkshopContracts/ViewModels/ComponentViewModel.cs @@ -16,5 +16,4 @@ namespace CarpentryWorkshopContracts.ViewModels [DisplayName("Цена")] public double Cost { get; set; } } - } diff --git a/CarpentryWorkshopDataModels/CarpentryWorkshopDataModels.csproj b/CarpentryWorkshopDataModels/CarpentryWorkshopDataModels.csproj index 132c02c..7fa6a8d 100644 --- a/CarpentryWorkshopDataModels/CarpentryWorkshopDataModels.csproj +++ b/CarpentryWorkshopDataModels/CarpentryWorkshopDataModels.csproj @@ -6,4 +6,7 @@ enable + + + diff --git a/CarpentryWorkshopDataModels/Models/IOrderModel.cs b/CarpentryWorkshopDataModels/Models/IOrderModel.cs index 7276b02..3b691f6 100644 --- a/CarpentryWorkshopDataModels/Models/IOrderModel.cs +++ b/CarpentryWorkshopDataModels/Models/IOrderModel.cs @@ -10,11 +10,7 @@ namespace CarpentryWorkshopDataModels.Models public interface IOrderModel : IId { int WoodId { get; } - string WoodName - { - get; - } - + string WoodName { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/CarpentryWorkshopFileImplement/Models/Order.cs b/CarpentryWorkshopFileImplement/Models/Order.cs index 1d03e65..a3625ba 100644 --- a/CarpentryWorkshopFileImplement/Models/Order.cs +++ b/CarpentryWorkshopFileImplement/Models/Order.cs @@ -14,14 +14,14 @@ namespace CarpentryWorkshopFileImplement.Models { public class Order : IOrderModel { - public int Id { get; set; } - public int WoodId { get; set; } - public string WoodName { get; set; } = string.Empty; - 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; } + public int Id { get; private set; } + public int WoodId { get; private set; } + public string WoodName { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; private set; } = DateTime.Now; + public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel model) { if (model == null) @@ -65,14 +65,7 @@ namespace CarpentryWorkshopFileImplement.Models { return; } - Id = model.Id; - WoodId = model.WoodId; - WoodName = model.WoodName; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; - DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { diff --git a/CarpentryWorkshopListImplement/Models/Order.cs b/CarpentryWorkshopListImplement/Models/Order.cs index f48279e..df34b1a 100644 --- a/CarpentryWorkshopListImplement/Models/Order.cs +++ b/CarpentryWorkshopListImplement/Models/Order.cs @@ -13,14 +13,14 @@ namespace CarpentryWorkshopListImplement.Models { public class Order : IOrderModel { - public int Id { get; set; } - public int WoodId { get; set; } - public string WoodName { get; set; } = string.Empty; - public int Count { get; set; } - public double Sum { get; set; } - public OrderStatus Status { get; set; } - public DateTime DateCreate { get; set; } - public DateTime? DateImplement { get; set; } + public int Id { get; private set; } + public int WoodId { get; private set; } + public string WoodName { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } + public DateTime DateCreate { get; private set; } + public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) { if (model == null) diff --git a/CarpentryWorkshopView/CarpentryWorkshopView.csproj b/CarpentryWorkshopView/CarpentryWorkshopView.csproj index 1afade8..11e9ad7 100644 --- a/CarpentryWorkshopView/CarpentryWorkshopView.csproj +++ b/CarpentryWorkshopView/CarpentryWorkshopView.csproj @@ -27,5 +27,4 @@ - \ No newline at end of file diff --git a/CarpentryWorkshopView/FormComponent.Designer.cs b/CarpentryWorkshopView/FormComponent.Designer.cs index df40fe6..97566b9 100644 --- a/CarpentryWorkshopView/FormComponent.Designer.cs +++ b/CarpentryWorkshopView/FormComponent.Designer.cs @@ -100,7 +100,7 @@ this.Controls.Add(this.ButtonCancel); this.Controls.Add(this.ButtonSave); this.Name = "FormComponent"; - this.Text = "FormComponent"; + this.Text = "Форма Компонента"; this.Load += new System.EventHandler(this.FormComponent_Load); this.ResumeLayout(false); this.PerformLayout();