From f5a68a28448045fbada879e009e0c627449578e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= Date: Sat, 25 May 2024 18:24:00 +0400 Subject: [PATCH] =?UTF-8?q?Revert=20"=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8?= =?UTF-8?q?=D0=BA=D1=82=D1=8B=20=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D0=BC"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 839c3dd3752f0ee9bda9df0fa32136bbc3b2050e. --- .../ImplementerLogic.cs | 129 ------------- .../ConfectioneryBusinessLogic/OrderLogic.cs | 67 ++----- .../WorkModeling.cs | 149 --------------- .../BindingModels/ImplementerBindingModel.cs | 22 --- .../BindingModels/OrderBindingModel.cs | 1 - .../IImplementerLogic.cs | 24 --- .../BussinessLogicsContracts/IOrderLogic.cs | 1 - .../BussinessLogicsContracts/IWorkProcess.cs | 16 -- .../SearchModels/ImplementerSearchModel.cs | 17 -- .../SearchModels/OrderSearchModel.cs | 5 +- .../StoragesContracts/IImplementerStorage.cs | 26 --- .../ViewModels/ImplementerViewModel.cs | 27 --- .../ViewModels/OrderViewModel.cs | 3 - .../IImplementerModel.cs | 16 -- .../ConfectioneryDataModels/IOrderModel.cs | 1 - .../ConfectioneryDatabase.cs | 2 - .../Implements/ImplementerStorage.cs | 91 --------- .../Implements/OrderStorage.cs | 37 +--- ... 20240502130846_InitialCreate.Designer.cs} | 45 +---- ...ate.cs => 20240502130846_InitialCreate.cs} | 30 --- .../ConfectioneryDatabaseModelSnapshot.cs | 43 ----- .../Models/Implementer.cs | 82 --------- .../Models/Order.cs | 12 +- .../DataFileSingleton.cs | 7 - .../Implements/ImplementerStorage.cs | 93 ---------- .../Implements/OrderStorage.cs | 27 +-- .../Models/Implementer.cs | 86 --------- .../Models/Order.cs | 7 - .../DataListSingleton.cs | 2 - .../Implements/ImplementerStorage.cs | 114 ------------ .../Implements/OrderStorage.cs | 30 +-- .../Models/Implementer.cs | 61 ------ .../Models/Order.cs | 6 +- .../Controllers/ImplementerController.cs | 107 ----------- Confectionery/ConfectioneryRestApi/Program.cs | 2 - .../FormImplementer.Designer.cs | 173 ------------------ .../ConfectioneryView/FormImplementer.cs | 104 ----------- .../ConfectioneryView/FormImplementer.resx | 120 ------------ .../ConfectioneryView/FormImplementers.cs | 106 ----------- .../FormImplementers.designer.cs | 127 ------------- .../ConfectioneryView/FormImplementers.resx | 120 ------------ .../ConfectioneryView/FormMain.Designer.cs | 63 ++++--- Confectionery/ConfectioneryView/FormMain.cs | 67 +++++-- Confectionery/ConfectioneryView/Program.cs | 5 - 44 files changed, 118 insertions(+), 2155 deletions(-) delete mode 100644 Confectionery/ConfectioneryBusinessLogic/ImplementerLogic.cs delete mode 100644 Confectionery/ConfectioneryBusinessLogic/WorkModeling.cs delete mode 100644 Confectionery/ConfectioneryContracts/BindingModels/ImplementerBindingModel.cs delete mode 100644 Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IImplementerLogic.cs delete mode 100644 Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IWorkProcess.cs delete mode 100644 Confectionery/ConfectioneryContracts/SearchModels/ImplementerSearchModel.cs delete mode 100644 Confectionery/ConfectioneryContracts/StoragesContracts/IImplementerStorage.cs delete mode 100644 Confectionery/ConfectioneryContracts/ViewModels/ImplementerViewModel.cs delete mode 100644 Confectionery/ConfectioneryDataModels/IImplementerModel.cs delete mode 100644 Confectionery/ConfectioneryDatabaseImplement/Implements/ImplementerStorage.cs rename Confectionery/ConfectioneryDatabaseImplement/Migrations/{20240502172709_InitialCreate.Designer.cs => 20240502130846_InitialCreate.Designer.cs} (82%) rename Confectionery/ConfectioneryDatabaseImplement/Migrations/{20240502172709_InitialCreate.cs => 20240502130846_InitialCreate.cs} (82%) delete mode 100644 Confectionery/ConfectioneryDatabaseImplement/Models/Implementer.cs delete mode 100644 Confectionery/ConfectioneryFileImplement/Implements/ImplementerStorage.cs delete mode 100644 Confectionery/ConfectioneryFileImplement/Models/Implementer.cs delete mode 100644 Confectionery/ConfectioneryListImplement/Implements/ImplementerStorage.cs delete mode 100644 Confectionery/ConfectioneryListImplement/Models/Implementer.cs delete mode 100644 Confectionery/ConfectioneryRestApi/Controllers/ImplementerController.cs delete mode 100644 Confectionery/ConfectioneryView/FormImplementer.Designer.cs delete mode 100644 Confectionery/ConfectioneryView/FormImplementer.cs delete mode 100644 Confectionery/ConfectioneryView/FormImplementer.resx delete mode 100644 Confectionery/ConfectioneryView/FormImplementers.cs delete mode 100644 Confectionery/ConfectioneryView/FormImplementers.designer.cs delete mode 100644 Confectionery/ConfectioneryView/FormImplementers.resx diff --git a/Confectionery/ConfectioneryBusinessLogic/ImplementerLogic.cs b/Confectionery/ConfectioneryBusinessLogic/ImplementerLogic.cs deleted file mode 100644 index 1780132..0000000 --- a/Confectionery/ConfectioneryBusinessLogic/ImplementerLogic.cs +++ /dev/null @@ -1,129 +0,0 @@ -using Microsoft.Extensions.Logging; -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.StoragesContracts; -using ConfectioneryContracts.ViewModels; -using ConfectioneryContracts.BussinessLogicsContracts; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryBusinessLogic -{ - public class ImplementerLogic : IImplementerLogic - { - private readonly ILogger _logger; - - private readonly IImplementerStorage _implementerStorage; - - public ImplementerLogic(ILogger logger, IImplementerStorage implementerStorage) - { - _logger = logger; - _implementerStorage = implementerStorage; - } - - public List? ReadList(ImplementerSearchModel? model) - { - _logger.LogInformation("ReadList. ImplementerFIO: {ImplementerFIO}. Id: {Id}", model?.ImplementerFIO, model?.Id); - var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model); - if (list == null) - { - _logger.LogWarning("ReadList return null list"); - return null; - } - _logger.LogInformation("ReadList. Count: {Count}", list.Count); - return list; - } - - public ImplementerViewModel? ReadElement(ImplementerSearchModel model) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - _logger.LogInformation("ReadElement. ImplementerFIO: {ImplementerFIO}. Id: {Id}", model.ImplementerFIO, model.Id); - var element = _implementerStorage.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(ImplementerBindingModel model) - { - CheckModel(model); - if (_implementerStorage.Insert(model) == null) - { - _logger.LogWarning("Insert operation failed"); - return false; - } - return true; - } - - public bool Update(ImplementerBindingModel model) - { - CheckModel(model); - if (_implementerStorage.Update(model) == null) - { - _logger.LogWarning("Update operation failed"); - return false; - } - return true; - } - - public bool Delete(ImplementerBindingModel model) - { - CheckModel(model, false); - _logger.LogInformation("Delete. Id: {Id}", model.Id); - if (_implementerStorage.Delete(model) == null) - { - _logger.LogWarning("Delete operation failed"); - return false; - } - return true; - } - - private void CheckModel(ImplementerBindingModel model, bool withParams = true) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - if (!withParams) - { - return; - } - if (string.IsNullOrEmpty(model.ImplementerFIO)) - { - throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO)); - } - if (string.IsNullOrEmpty(model.Password)) - { - throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.Password)); - } - if (model.WorkExperience <= 0) - { - throw new ArgumentNullException("Стаж работы исполнителя должен быть больше 0", nameof(model.WorkExperience)); - } - if (model.Qualification <= 0) - { - throw new ArgumentNullException("Квалификация исполнителя должен быть больше 0", nameof(model.Qualification)); - } - _logger.LogInformation("Implementer. Id: {Id}. ImplementerFIO: {ImplementerFIO}. Password: {Password}. Qualification: {Qualification}. " + - "WorkExperience: {WorkExperience}", model.Id, model.ImplementerFIO, model.Password, model.Qualification, model.WorkExperience); - var element = _implementerStorage.GetElement(new ImplementerSearchModel - { - ImplementerFIO = model.ImplementerFIO - }); - if (element != null && element.Id != model.Id) - { - throw new InvalidOperationException("Исполнитель с таким ФИО уже существует"); - } - } - } -} diff --git a/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs b/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs index 7faac9e..c12ff73 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs @@ -17,7 +17,6 @@ namespace ConfectioneryBusinessLogic { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; - static readonly object locker = new(); public OrderLogic(ILogger logger, IOrderStorage orderStorage) { @@ -38,23 +37,6 @@ namespace ConfectioneryBusinessLogic return list; } - public OrderViewModel? ReadElement(OrderSearchModel model) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - _logger.LogInformation("ReadElement. Id: {Id}", model.Id); - var element = _orderStorage.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 CreateOrder(OrderBindingModel model) { CheckModel(model); @@ -74,10 +56,7 @@ namespace ConfectioneryBusinessLogic public bool TakeOrderInWork(OrderBindingModel model) { - lock (locker) - { - return ChangeStatus(model, OrderStatus.Выполняется); - } + return ChangeStatus(model, OrderStatus.Выполняется); } public bool FinishOrder(OrderBindingModel model) @@ -93,37 +72,29 @@ namespace ConfectioneryBusinessLogic private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) { CheckModel(model, false); - var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); - if (order == null) + var element = _orderStorage.GetElement(new OrderSearchModel() { - _logger.LogWarning("Change status operation failed. Order not found"); - return false; - } - if (order.Status + 1 != requiredStatus) + Id = model.Id + }); + if (element == null) { - _logger.LogWarning("Change status operation failed. Incorrect new status: {newStatus}. Current status: {currStatus}", - requiredStatus, order.Status); - return false; + throw new ArgumentNullException(nameof(element)); } - model.Status = requiredStatus; - if (order.ImplementerId.HasValue) + model.Status = element.Status; + if (requiredStatus - model.Status == 1) { - model.ImplementerId = order.ImplementerId; + model.Status = requiredStatus; + if (model.Status == OrderStatus.Готов) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; } - if (model.Status == OrderStatus.Готов) - { - model.DateImplement = DateTime.Now; - } - else - { - model.DateImplement = order.DateImplement; - } - if (_orderStorage.Update(model) == null) - { - _logger.LogWarning("Change status operation failed"); - return false; - } - return true; + _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); + throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); } private void CheckModel(OrderBindingModel model, bool withParams = true) diff --git a/Confectionery/ConfectioneryBusinessLogic/WorkModeling.cs b/Confectionery/ConfectioneryBusinessLogic/WorkModeling.cs deleted file mode 100644 index f106a69..0000000 --- a/Confectionery/ConfectioneryBusinessLogic/WorkModeling.cs +++ /dev/null @@ -1,149 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.BussinessLogicsContracts; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.ViewModels; -using ConfectioneryDataModels.Enums; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryBusinessLogic -{ - public class WorkModeling : IWorkProcess - { - private readonly ILogger _logger; - - private readonly Random _rnd; - - private IOrderLogic? _orderLogic; - - public WorkModeling(ILogger logger) - { - _logger = logger; - _rnd = new Random(1000); - } - - public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) - { - _orderLogic = orderLogic; - var implementers = implementerLogic.ReadList(null); - if (implementers == null) - { - _logger.LogWarning("DoWork. Implementers is null"); - return; - } - var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят }); - if (orders == null || orders.Count == 0) - { - _logger.LogWarning("DoWork. Orders is null or empty"); - return; - } - _logger.LogDebug("DoWork for {Count} orders", orders.Count); - foreach (var implementer in implementers) - { - Task.Run(() => WorkerWorkAsync(implementer, orders)); - } - } - - /// - /// Иммитация работы исполнителя - /// - /// - /// - private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) - { - if (_orderLogic == null || implementer == null) - { - return; - } - await RunOrderInWork(implementer); - - await Task.Run(() => - { - foreach (var order in orders) - { - try - { - _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); - // пытаемся назначить заказ на исполнителя - _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = order.Id, - ImplementerId = implementer.Id - }); - // делаем работу - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); - _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); - _orderLogic.FinishOrder(new OrderBindingModel - { - Id = order.Id - }); - // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); - } - // кто-то мог уже перехватить заказ, игнорируем ошибку - catch (InvalidOperationException ex) - { - _logger.LogWarning(ex, "Error try get work"); - } - // заканчиваем выполнение имитации в случае иной ошибки - catch (Exception ex) - { - _logger.LogError(ex, "Error while do work"); - throw; - } - } - }); - } - - /// - /// Ищем заказ, которые уже в работе (вдруг исполнителя прервали) - /// - /// - /// - private async Task RunOrderInWork(ImplementerViewModel implementer) - { - if (_orderLogic == null || implementer == null) - { - return; - } - try - { - var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel - { - ImplementerId = implementer.Id, - Status = OrderStatus.Выполняется - })); - if (runOrder == null) - { - return; - } - - _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); - // доделываем работу - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count); - _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); - _orderLogic.FinishOrder(new OrderBindingModel - { - Id = runOrder.Id - }); - // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); - } - // заказа может не быть, просто игнорируем ошибку - catch (InvalidOperationException ex) - { - _logger.LogWarning(ex, "Error try get work"); - } - // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации - catch (Exception ex) - { - _logger.LogError(ex, "Error while do work"); - throw; - } - } - } -} diff --git a/Confectionery/ConfectioneryContracts/BindingModels/ImplementerBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/ImplementerBindingModel.cs deleted file mode 100644 index 042eb3a..0000000 --- a/Confectionery/ConfectioneryContracts/BindingModels/ImplementerBindingModel.cs +++ /dev/null @@ -1,22 +0,0 @@ -using ConfectioneryDataModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryContracts.BindingModels -{ - public class ImplementerBindingModel : IImplementerModel - { - public int Id { get; set; } - - public string ImplementerFIO { get; set; } = string.Empty; - - public string Password { get; set; } = string.Empty; - - public int WorkExperience { get; set; } - - public int Qualification { get; set; } - } -} diff --git a/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs index 3ce708d..d51f207 100644 --- a/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs +++ b/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs @@ -13,7 +13,6 @@ namespace ConfectioneryContracts.BindingModels public int Id { get; set; } public int PastryId { get; set; } public int ClientId { get; set; } - public int? ImplementerId { get; set; } public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IImplementerLogic.cs b/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IImplementerLogic.cs deleted file mode 100644 index 5307220..0000000 --- a/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IImplementerLogic.cs +++ /dev/null @@ -1,24 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryContracts.BussinessLogicsContracts -{ - public interface IImplementerLogic - { - List? ReadList(ImplementerSearchModel? model); - - ImplementerViewModel? ReadElement(ImplementerSearchModel model); - - bool Create(ImplementerBindingModel model); - - bool Update(ImplementerBindingModel model); - - bool Delete(ImplementerBindingModel model); - } -} diff --git a/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IOrderLogic.cs b/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IOrderLogic.cs index 150ca61..c37c11a 100644 --- a/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IOrderLogic.cs +++ b/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IOrderLogic.cs @@ -12,7 +12,6 @@ namespace ConfectioneryContracts.BussinessLogicsContracts public interface IOrderLogic { List? ReadList(OrderSearchModel? model); - OrderViewModel? ReadElement(OrderSearchModel model); bool CreateOrder(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model); bool FinishOrder(OrderBindingModel model); diff --git a/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IWorkProcess.cs b/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IWorkProcess.cs deleted file mode 100644 index 7e1d68b..0000000 --- a/Confectionery/ConfectioneryContracts/BussinessLogicsContracts/IWorkProcess.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryContracts.BussinessLogicsContracts -{ - public interface IWorkProcess - { - /// - /// Запуск работ - /// - void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic); - } -} diff --git a/Confectionery/ConfectioneryContracts/SearchModels/ImplementerSearchModel.cs b/Confectionery/ConfectioneryContracts/SearchModels/ImplementerSearchModel.cs deleted file mode 100644 index 008af4b..0000000 --- a/Confectionery/ConfectioneryContracts/SearchModels/ImplementerSearchModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryContracts.SearchModels -{ - public class ImplementerSearchModel - { - public int? Id { get; set; } - - public string? ImplementerFIO { get; set; } - - public string? Password { get; set; } - } -} diff --git a/Confectionery/ConfectioneryContracts/SearchModels/OrderSearchModel.cs b/Confectionery/ConfectioneryContracts/SearchModels/OrderSearchModel.cs index bf92be8..d636d99 100644 --- a/Confectionery/ConfectioneryContracts/SearchModels/OrderSearchModel.cs +++ b/Confectionery/ConfectioneryContracts/SearchModels/OrderSearchModel.cs @@ -1,5 +1,4 @@ -using ConfectioneryDataModels.Enums; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,9 +10,7 @@ namespace ConfectioneryContracts.SearchModels { public int? Id { get; set; } public int? ClientId { get; set; } - public int? ImplementerId { get; set; } public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } - public OrderStatus? Status { get; set; } } } diff --git a/Confectionery/ConfectioneryContracts/StoragesContracts/IImplementerStorage.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IImplementerStorage.cs deleted file mode 100644 index 88640dc..0000000 --- a/Confectionery/ConfectioneryContracts/StoragesContracts/IImplementerStorage.cs +++ /dev/null @@ -1,26 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryContracts.StoragesContracts -{ - public interface IImplementerStorage - { - List GetFullList(); - - List GetFilteredList(ImplementerSearchModel model); - - ImplementerViewModel? GetElement(ImplementerSearchModel model); - - ImplementerViewModel? Insert(ImplementerBindingModel model); - - ImplementerViewModel? Update(ImplementerBindingModel model); - - ImplementerViewModel? Delete(ImplementerBindingModel model); - } -} diff --git a/Confectionery/ConfectioneryContracts/ViewModels/ImplementerViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/ImplementerViewModel.cs deleted file mode 100644 index 3d038bb..0000000 --- a/Confectionery/ConfectioneryContracts/ViewModels/ImplementerViewModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using ConfectioneryDataModels; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryContracts.ViewModels -{ - public class ImplementerViewModel : IImplementerModel - { - public int Id { get; set; } - - [DisplayName("ФИО исполнителя")] - public string ImplementerFIO { get; set; } = string.Empty; - - [DisplayName("Пароль")] - public string Password { get; set; } = string.Empty; - - [DisplayName("Стаж работы")] - public int WorkExperience { get; set; } - - [DisplayName("Квалификация")] - public int Qualification { get; set; } - } -} diff --git a/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs index 5930a91..963535d 100644 --- a/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs +++ b/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs @@ -20,9 +20,6 @@ namespace ConfectioneryContracts.ViewModels public int ClientId { get; set; } [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } = string.Empty; - public int? ImplementerId { get; set; } - [DisplayName("ФИО исполнителя")] - public string ImplementerFIO { get; set; } = string.Empty; public int Count { get; set; } [DisplayName("Сумма")] public double Sum { get; set; } diff --git a/Confectionery/ConfectioneryDataModels/IImplementerModel.cs b/Confectionery/ConfectioneryDataModels/IImplementerModel.cs deleted file mode 100644 index e99aed8..0000000 --- a/Confectionery/ConfectioneryDataModels/IImplementerModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryDataModels -{ - public interface IImplementerModel : IId - { - string ImplementerFIO { get; } - string Password { get; } - int WorkExperience { get; } - int Qualification { get; } - } -} diff --git a/Confectionery/ConfectioneryDataModels/IOrderModel.cs b/Confectionery/ConfectioneryDataModels/IOrderModel.cs index ce6775b..87957e5 100644 --- a/Confectionery/ConfectioneryDataModels/IOrderModel.cs +++ b/Confectionery/ConfectioneryDataModels/IOrderModel.cs @@ -11,7 +11,6 @@ namespace ConfectioneryDataModels.Models { int PastryId { get; } int ClientId { get; } - int? ImplementerId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs b/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs index 0ba3b3b..60c3b0b 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs @@ -28,7 +28,5 @@ namespace ConfectioneryDatabaseImplement public virtual DbSet Orders { set; get; } public virtual DbSet Clients { set; get; } - - public virtual DbSet Implementers { set; get; } } } diff --git a/Confectionery/ConfectioneryDatabaseImplement/Implements/ImplementerStorage.cs b/Confectionery/ConfectioneryDatabaseImplement/Implements/ImplementerStorage.cs deleted file mode 100644 index d3b14c9..0000000 --- a/Confectionery/ConfectioneryDatabaseImplement/Implements/ImplementerStorage.cs +++ /dev/null @@ -1,91 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.StoragesContracts; -using ConfectioneryContracts.ViewModels; -using ConfectioneryDatabaseImplement.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryDatabaseImplement.Implements -{ - public class ImplementerStorage : IImplementerStorage - { - public List GetFullList() - { - using var context = new ConfectioneryDatabase(); - return context.Implementers - .Select(x => x.GetViewModel) - .ToList(); - } - - public List GetFilteredList(ImplementerSearchModel model) - { - if (string.IsNullOrEmpty(model.ImplementerFIO)) - { - return new(); - } - using var context = new ConfectioneryDatabase(); - return context.Implementers - .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)) - .Select(x => x.GetViewModel) - .ToList(); - } - - public ImplementerViewModel? GetElement(ImplementerSearchModel model) - { - if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue) - { - return null; - } - using var context = new ConfectioneryDatabase(); - return context.Implementers - .FirstOrDefault(x => - (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO - && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) - || (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; - } - - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - var newImplementer = Implementer.Create(model); - if (newImplementer == null) - { - return null; - } - using var context = new ConfectioneryDatabase(); - context.Implementers.Add(newImplementer); - context.SaveChanges(); - return newImplementer.GetViewModel; - } - - public ImplementerViewModel? Update(ImplementerBindingModel model) - { - using var context = new ConfectioneryDatabase(); - var implementer = context.Implementers.FirstOrDefault(x => x.Id == model.Id); - if (implementer == null) - { - return null; - } - implementer.Update(model); - context.SaveChanges(); - return implementer.GetViewModel; - } - - public ImplementerViewModel? Delete(ImplementerBindingModel model) - { - using var context = new ConfectioneryDatabase(); - var element = context.Implementers.FirstOrDefault(x => x.Id == model.Id); - if (element != null) - { - context.Implementers.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - } -} diff --git a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs index 23b10b7..7b303d7 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs @@ -15,7 +15,6 @@ namespace ConfectioneryDatabaseImplement.Implements return context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) .Select(x => x.GetViewModel) .ToList(); } @@ -28,7 +27,6 @@ namespace ConfectioneryDatabaseImplement.Implements return context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) .Where(x => x.Id == model.Id) .Select(x => x.GetViewModel) .ToList(); @@ -38,7 +36,6 @@ namespace ConfectioneryDatabaseImplement.Implements return context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Select(x => x.GetViewModel) .ToList(); @@ -48,37 +45,16 @@ namespace ConfectioneryDatabaseImplement.Implements return context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) .Where(x => x.ClientId == model.ClientId) .Select(x => x.GetViewModel) .ToList(); } - else if (model.ImplementerId.HasValue) - { - return context.Orders - .Include(x => x.Pastry) - .Include(x => x.Client) - .Include(x => x.Implementer) - .Where(x => x.ImplementerId == model.ImplementerId) - .Select(x => x.GetViewModel) - .ToList(); - } - else if (model.Status != null) - { - return context.Orders - .Include(x => x.Pastry) - .Include(x => x.Client) - .Include(x => x.Implementer) - .Where(x => x.Status.Equals(model.Status)) - .Select(x => x.GetViewModel) - .ToList(); - } return new(); } public OrderViewModel? GetElement(OrderSearchModel model) { - if (!model.Id.HasValue && !model.ImplementerId.HasValue) + if (!model.Id.HasValue) { return null; } @@ -86,11 +62,7 @@ namespace ConfectioneryDatabaseImplement.Implements return context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) - .FirstOrDefault(x => - model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId && model.Status != null && x.Status.Equals(model.Status) - || model.Status == null && model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId - || model.Id.HasValue && x.Id == model.Id) + .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } @@ -106,8 +78,7 @@ namespace ConfectioneryDatabaseImplement.Implements context.SaveChanges(); return context.Orders .Include(x => x.Pastry) - .Include(x => x.Client) - .Include(x => x.Implementer) + .Include(x => x.Client) .FirstOrDefault(x => x.Id == newOrder.Id) ?.GetViewModel; } @@ -125,7 +96,6 @@ namespace ConfectioneryDatabaseImplement.Implements return context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } @@ -139,7 +109,6 @@ namespace ConfectioneryDatabaseImplement.Implements var deletedElement = context.Orders .Include(x => x.Pastry) .Include(x => x.Client) - .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; context.Orders.Remove(element); diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502172709_InitialCreate.Designer.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502130846_InitialCreate.Designer.cs similarity index 82% rename from Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502172709_InitialCreate.Designer.cs rename to Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502130846_InitialCreate.Designer.cs index 1eadbf0..6ade566 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502172709_InitialCreate.Designer.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502130846_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ConfectioneryDatabaseImplement.Migrations { [DbContext(typeof(ConfectioneryDatabase))] - [Migration("20240502172709_InitialCreate")] + [Migration("20240502130846_InitialCreate")] partial class InitialCreate { /// @@ -70,33 +70,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.ToTable("Components"); }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -117,9 +90,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); - b.Property("ImplementerId") - .HasColumnType("int"); - b.Property("PastryId") .HasColumnType("int"); @@ -133,8 +103,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("ImplementerId"); - b.HasIndex("PastryId"); b.ToTable("Orders"); @@ -194,10 +162,6 @@ namespace ConfectioneryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", "Implementer") - .WithMany("Orders") - .HasForeignKey("ImplementerId"); - b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") .WithMany("Orders") .HasForeignKey("PastryId") @@ -206,8 +170,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("Client"); - b.Navigation("Implementer"); - b.Navigation("Pastry"); }); @@ -240,11 +202,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("PastryComponents"); }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b => - { - b.Navigation("Orders"); - }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => { b.Navigation("Components"); diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502172709_InitialCreate.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502130846_InitialCreate.cs similarity index 82% rename from Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502172709_InitialCreate.cs rename to Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502130846_InitialCreate.cs index 3171066..9604503 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502172709_InitialCreate.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240502130846_InitialCreate.cs @@ -40,22 +40,6 @@ namespace ConfectioneryDatabaseImplement.Migrations table.PrimaryKey("PK_Components", x => x.Id); }); - migrationBuilder.CreateTable( - name: "Implementers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - WorkExperience = table.Column(type: "int", nullable: false), - Qualification = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Implementers", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Pastries", columns: table => new @@ -78,7 +62,6 @@ namespace ConfectioneryDatabaseImplement.Migrations .Annotation("SqlServer:Identity", "1, 1"), PastryId = table.Column(type: "int", nullable: false), ClientId = table.Column(type: "int", nullable: false), - ImplementerId = table.Column(type: "int", nullable: true), Count = table.Column(type: "int", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), @@ -94,11 +77,6 @@ namespace ConfectioneryDatabaseImplement.Migrations principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Orders_Implementers_ImplementerId", - column: x => x.ImplementerId, - principalTable: "Implementers", - principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Pastries_PastryId", column: x => x.PastryId, @@ -139,11 +117,6 @@ namespace ConfectioneryDatabaseImplement.Migrations table: "Orders", column: "ClientId"); - migrationBuilder.CreateIndex( - name: "IX_Orders_ImplementerId", - table: "Orders", - column: "ImplementerId"); - migrationBuilder.CreateIndex( name: "IX_Orders_PastryId", table: "Orders", @@ -172,9 +145,6 @@ namespace ConfectioneryDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Clients"); - migrationBuilder.DropTable( - name: "Implementers"); - migrationBuilder.DropTable( name: "Components"); diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs index 6d2b6bc..f79d3aa 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs @@ -67,33 +67,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.ToTable("Components"); }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -114,9 +87,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); - b.Property("ImplementerId") - .HasColumnType("int"); - b.Property("PastryId") .HasColumnType("int"); @@ -130,8 +100,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("ImplementerId"); - b.HasIndex("PastryId"); b.ToTable("Orders"); @@ -191,10 +159,6 @@ namespace ConfectioneryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", "Implementer") - .WithMany("Orders") - .HasForeignKey("ImplementerId"); - b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") .WithMany("Orders") .HasForeignKey("PastryId") @@ -203,8 +167,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("Client"); - b.Navigation("Implementer"); - b.Navigation("Pastry"); }); @@ -237,11 +199,6 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("PastryComponents"); }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b => - { - b.Navigation("Orders"); - }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => { b.Navigation("Components"); diff --git a/Confectionery/ConfectioneryDatabaseImplement/Models/Implementer.cs b/Confectionery/ConfectioneryDatabaseImplement/Models/Implementer.cs deleted file mode 100644 index adafe95..0000000 --- a/Confectionery/ConfectioneryDatabaseImplement/Models/Implementer.cs +++ /dev/null @@ -1,82 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.ViewModels; -using ConfectioneryDataModels; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryDatabaseImplement.Models -{ - public class Implementer : IImplementerModel - { - public int Id { get; set; } - - [Required] - public string ImplementerFIO { get; set; } = string.Empty; - - [Required] - public string Password { get; set; } = string.Empty; - - [Required] - public int WorkExperience { get; set; } - - [Required] - public int Qualification { get; set; } - - [ForeignKey("ImplementerId")] - public virtual List Orders { get; set; } = new(); - - public static Implementer? Create(ImplementerBindingModel model) - { - if (model == null) - { - return null; - } - return new Implementer() - { - Id = model.Id, - ImplementerFIO = model.ImplementerFIO, - Password = model.Password, - WorkExperience = model.WorkExperience, - Qualification = model.Qualification - }; - } - - public static Implementer Create(ImplementerViewModel model) - { - return new Implementer - { - Id = model.Id, - ImplementerFIO = model.ImplementerFIO, - Password = model.Password, - WorkExperience = model.WorkExperience, - Qualification = model.Qualification - }; - } - - public void Update(ImplementerBindingModel model) - { - if (model == null) - { - return; - } - ImplementerFIO = model.ImplementerFIO; - Password = model.Password; - WorkExperience = model.WorkExperience; - Qualification = model.Qualification; - } - - public ImplementerViewModel GetViewModel => new() - { - Id = Id, - ImplementerFIO = ImplementerFIO, - Password = Password, - WorkExperience = WorkExperience, - Qualification = Qualification - }; - } -} diff --git a/Confectionery/ConfectioneryDatabaseImplement/Models/Order.cs b/Confectionery/ConfectioneryDatabaseImplement/Models/Order.cs index 78dbecb..0c7c780 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Models/Order.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Models/Order.cs @@ -21,8 +21,6 @@ namespace ConfectioneryDatabaseImplement.Models [Required] public int ClientId { get; set; } - public int? ImplementerId { get; private set; } - [Required] public int Count { get; set; } @@ -41,8 +39,6 @@ namespace ConfectioneryDatabaseImplement.Models public virtual Client Client { get; set; } - public virtual Implementer? Implementer { get; set; } - public static Order? Create(OrderBindingModel? model) { if (model == null) @@ -54,7 +50,6 @@ namespace ConfectioneryDatabaseImplement.Models Id = model.Id, PastryId = model.PastryId, ClientId = model.ClientId, - ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -71,7 +66,6 @@ namespace ConfectioneryDatabaseImplement.Models } Status = model.Status; DateImplement = model.DateImplement; - ImplementerId = model.ImplementerId; } public OrderViewModel GetViewModel => new() @@ -79,15 +73,13 @@ namespace ConfectioneryDatabaseImplement.Models Id = Id, PastryId = PastryId, ClientId = ClientId, - ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status, DateCreate = DateCreate, DateImplement = DateImplement, - PastryName = Pastry.PastryName ?? string.Empty, - ClientFIO = Client.ClientFIO ?? string.Empty, - ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty + PastryName = Pastry.PastryName, + ClientFIO = Client.ClientFIO }; } } diff --git a/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs b/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs index 4cc4c9d..4b3ece6 100644 --- a/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs +++ b/Confectionery/ConfectioneryFileImplement/DataFileSingleton.cs @@ -20,8 +20,6 @@ namespace ConfectioneryFileImplement private readonly string ClientFileName = "Client.xml"; - private readonly string ImplementerFileName = "Implementer.xml"; - public List Components { get; private set; } public List Orders { get; private set; } @@ -30,8 +28,6 @@ namespace ConfectioneryFileImplement public List Clients { get; private set; } - public List Implementers { get; private set; } - public static DataFileSingleton GetInstance() { if (instance == null) @@ -49,15 +45,12 @@ namespace ConfectioneryFileImplement public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); - public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement); - private DataFileSingleton() { Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; Pastries = LoadData(PastryFileName, "Pastry", x => Pastry.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; - Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!; } private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) diff --git a/Confectionery/ConfectioneryFileImplement/Implements/ImplementerStorage.cs b/Confectionery/ConfectioneryFileImplement/Implements/ImplementerStorage.cs deleted file mode 100644 index 2a9cced..0000000 --- a/Confectionery/ConfectioneryFileImplement/Implements/ImplementerStorage.cs +++ /dev/null @@ -1,93 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.StoragesContracts; -using ConfectioneryContracts.ViewModels; -using ConfectioneryFileImplement.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryFileImplement.Implements -{ - public class ImplementerStorage : IImplementerStorage - { - private readonly DataFileSingleton source; - - public ImplementerStorage() - { - source = DataFileSingleton.GetInstance(); - } - - public List GetFullList() - { - return source.Implementers - .Select(x => x.GetViewModel) - .ToList(); - } - - public List GetFilteredList(ImplementerSearchModel model) - { - if (string.IsNullOrEmpty(model.ImplementerFIO)) - { - return new(); - } - return source.Implementers - .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)) - .Select(x => x.GetViewModel) - .ToList(); - } - - public ImplementerViewModel? GetElement(ImplementerSearchModel model) - { - if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue) - { - return null; - } - return source.Implementers - .FirstOrDefault(x => - (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO - && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) - || (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; - } - - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x => x.Id) + 1 : 1; - var newImplementer = Implementer.Create(model); - if (newImplementer == null) - { - return null; - } - source.Implementers.Add(newImplementer); - source.SaveImplementers(); - return newImplementer.GetViewModel; - } - - public ImplementerViewModel? Update(ImplementerBindingModel model) - { - var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id); - if (implementer == null) - { - return null; - } - implementer.Update(model); - source.SaveImplementers(); - return implementer.GetViewModel; - } - - public ImplementerViewModel? Delete(ImplementerBindingModel model) - { - var element = source.Implementers.FirstOrDefault(x => x.Id == model.Id); - if (element != null) - { - source.Implementers.Remove(element); - source.SaveImplementers(); - return element.GetViewModel; - } - return null; - } - } -} diff --git a/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs index ee9639d..dc5ba8a 100644 --- a/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs @@ -50,34 +50,21 @@ namespace ConfectioneryFileImplement.Implements .Select(x => AddInfo(x.GetViewModel)) .ToList(); } - else if (model.ImplementerId.HasValue) - { - return source.Orders - .Where(x => x.ImplementerId == model.ImplementerId) - .Select(x => AddInfo(x.GetViewModel)) - .ToList(); - } - else if (model.Status != null) - { - return source.Orders - .Where(x => x.Status.Equals(model.Status)) - .Select(x => AddInfo(x.GetViewModel)) - .ToList(); - } return new(); } public OrderViewModel? GetElement(OrderSearchModel model) { - if (!model.Id.HasValue && !model.ImplementerId.HasValue) + if (!model.Id.HasValue) { return null; } - var order = source.Orders.FirstOrDefault(x => - model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId && model.Status != null && x.Status.Equals(model.Status) - || model.Status == null && model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId - || model.Id.HasValue && x.Id == model.Id); - return order?.GetViewModel != null ? AddInfo(order.GetViewModel) : null; + var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); + if (order == null) + { + return null; + } + return AddInfo(order.GetViewModel); } public OrderViewModel? Insert(OrderBindingModel model) diff --git a/Confectionery/ConfectioneryFileImplement/Models/Implementer.cs b/Confectionery/ConfectioneryFileImplement/Models/Implementer.cs deleted file mode 100644 index 6c59d67..0000000 --- a/Confectionery/ConfectioneryFileImplement/Models/Implementer.cs +++ /dev/null @@ -1,86 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.ViewModels; -using ConfectioneryDataModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace ConfectioneryFileImplement.Models -{ - internal class Implementer : IImplementerModel - { - public int Id { get; set; } - - public string ImplementerFIO { get; set; } = string.Empty; - - public string Password { get; set; } = string.Empty; - - public int WorkExperience { get; set; } - - public int Qualification { get; set; } - - public static Implementer? Create(ImplementerBindingModel? model) - { - if (model == null) - { - return null; - } - return new Implementer() - { - Id = model.Id, - ImplementerFIO = model.ImplementerFIO, - Password = model.Password, - WorkExperience = model.WorkExperience, - Qualification = model.Qualification - }; - } - - public static Implementer? Create(XElement element) - { - if (element == null) - { - return null; - } - return new Implementer() - { - Id = Convert.ToInt32(element.Attribute("Id")!.Value), - ImplementerFIO = element.Element("ImplementerFIO")!.Value, - Password = element.Element("Password")!.Value, - WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value), - Qualification = Convert.ToInt32(element.Element("Qualification")!.Value) - }; - } - - public void Update(ImplementerBindingModel? model) - { - if (model == null) - { - return; - } - ImplementerFIO = model.ImplementerFIO; - Password = model.Password; - WorkExperience = model.WorkExperience; - Qualification = model.Qualification; - } - - public ImplementerViewModel GetViewModel => new() - { - Id = Id, - ImplementerFIO = ImplementerFIO, - Password = Password, - WorkExperience = WorkExperience, - Qualification = Qualification - }; - - public XElement GetXElement => new("Implementer", - new XAttribute("Id", Id), - new XElement("ImplementerFIO", ImplementerFIO), - new XElement("Password", Password), - new XElement("WorkExperience", WorkExperience), - new XElement("Qualification", Qualification) - ); - } -} diff --git a/Confectionery/ConfectioneryFileImplement/Models/Order.cs b/Confectionery/ConfectioneryFileImplement/Models/Order.cs index 3e6f358..af86c63 100644 --- a/Confectionery/ConfectioneryFileImplement/Models/Order.cs +++ b/Confectionery/ConfectioneryFileImplement/Models/Order.cs @@ -19,8 +19,6 @@ namespace ConfectioneryFileImplement.Models public int ClientId { get; private set; } - public int? ImplementerId { get; private set; } - public int Count { get; private set; } public double Sum { get; private set; } @@ -42,7 +40,6 @@ namespace ConfectioneryFileImplement.Models Id = model.Id, PastryId = model.PastryId, ClientId = model.ClientId, - ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -62,7 +59,6 @@ namespace ConfectioneryFileImplement.Models Id = Convert.ToInt32(element.Attribute("Id")!.Value), PastryId = Convert.ToInt32(element.Element("PastryId")!.Value), ClientId = Convert.ToInt32(element.Element("ClientId")!.Value), - ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), @@ -80,7 +76,6 @@ namespace ConfectioneryFileImplement.Models } Status = model.Status; DateImplement = model.DateImplement; - ImplementerId = model.ImplementerId; } public OrderViewModel GetViewModel => new() @@ -88,7 +83,6 @@ namespace ConfectioneryFileImplement.Models Id = Id, PastryId = PastryId, ClientId = ClientId, - ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status, @@ -100,7 +94,6 @@ namespace ConfectioneryFileImplement.Models new XAttribute("Id", Id), new XElement("PastryId", PastryId), new XElement("ClientId", ClientId), - new XElement("ImplementerId", ImplementerId), new XElement("Count", Count.ToString()), new XElement("Sum", Sum.ToString()), new XElement("Status", Status.ToString()), diff --git a/Confectionery/ConfectioneryListImplement/DataListSingleton.cs b/Confectionery/ConfectioneryListImplement/DataListSingleton.cs index d4931f6..77eab83 100644 --- a/Confectionery/ConfectioneryListImplement/DataListSingleton.cs +++ b/Confectionery/ConfectioneryListImplement/DataListSingleton.cs @@ -14,14 +14,12 @@ namespace ConfectioneryListImplement public List Orders { get; set; } public List Pastries { get; set; } public List Clients { get; set; } - public List Implementers { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); Pastries = new List(); Clients = new List(); - Implementers = new List(); } public static DataListSingleton GetInstance() diff --git a/Confectionery/ConfectioneryListImplement/Implements/ImplementerStorage.cs b/Confectionery/ConfectioneryListImplement/Implements/ImplementerStorage.cs deleted file mode 100644 index 431d5eb..0000000 --- a/Confectionery/ConfectioneryListImplement/Implements/ImplementerStorage.cs +++ /dev/null @@ -1,114 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.StoragesContracts; -using ConfectioneryContracts.ViewModels; -using ConfectioneryListImplement.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryListImplement.Implements -{ - public class ImplementerStorage : IImplementerStorage - { - private readonly DataListSingleton _source; - - public ImplementerStorage() - { - _source = DataListSingleton.GetInstance(); - } - - public List GetFullList() - { - var result = new List(); - foreach (var implementer in _source.Implementers) - { - result.Add(implementer.GetViewModel); - } - return result; - } - - public List GetFilteredList(ImplementerSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.ImplementerFIO)) - { - return result; - } - foreach (var implementer in _source.Implementers) - { - if (implementer.ImplementerFIO.Contains(model.ImplementerFIO)) - { - result.Add(implementer.GetViewModel); - } - } - return result; - } - - public ImplementerViewModel? GetElement(ImplementerSearchModel model) - { - if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue) - { - return null; - } - foreach (var implementer in _source.Implementers) - { - if ((!string.IsNullOrEmpty(model.ImplementerFIO) && implementer.ImplementerFIO == model.ImplementerFIO - && (string.IsNullOrEmpty(model.Password) || implementer.Password == model.Password)) - || (model.Id.HasValue && implementer.Id == model.Id)) - { - return implementer.GetViewModel; - } - } - return null; - } - - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - model.Id = 1; - foreach (var implementer in _source.Implementers) - { - if (model.Id <= implementer.Id) - { - model.Id = implementer.Id + 1; - } - } - var newImplementer = Implementer.Create(model); - if (newImplementer == null) - { - return null; - } - _source.Implementers.Add(newImplementer); - return newImplementer.GetViewModel; - } - - public ImplementerViewModel? Update(ImplementerBindingModel model) - { - foreach (var implementer in _source.Implementers) - { - if (implementer.Id == model.Id) - { - implementer.Update(model); - return implementer.GetViewModel; - } - } - return null; - } - - public ImplementerViewModel? Delete(ImplementerBindingModel model) - { - for (int i = 0; i < _source.Implementers.Count; ++i) - { - if (_source.Implementers[i].Id == model.Id) - { - var element = _source.Implementers[i]; - _source.Implementers.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} diff --git a/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs index 9756253..361e1b9 100644 --- a/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs @@ -63,32 +63,12 @@ namespace ConfectioneryListImplement.Implements } } } - else if (model.ImplementerId.HasValue) - { - foreach (var order in _source.Orders) - { - if (order.ImplementerId == model.ImplementerId) - { - result.Add(AddInfo(order.GetViewModel)); - } - } - } - else if (model.Status != null) - { - foreach (var order in _source.Orders) - { - if (order.Status.Equals(model.Status)) - { - result.Add(AddInfo(order.GetViewModel)); - } - } - } return result; } public OrderViewModel? GetElement(OrderSearchModel model) { - if (!model.Id.HasValue && !model.ImplementerId.HasValue) + if (!model.Id.HasValue) { return null; } @@ -98,14 +78,6 @@ namespace ConfectioneryListImplement.Implements { return AddInfo(order.GetViewModel); } - if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && order.Status.Equals(model.Status)) - { - return AddInfo(order.GetViewModel); - } - if (model.ImplementerId.HasValue && model.Status == null && order.ImplementerId == model.ImplementerId) - { - return AddInfo(order.GetViewModel); - } } return null; } diff --git a/Confectionery/ConfectioneryListImplement/Models/Implementer.cs b/Confectionery/ConfectioneryListImplement/Models/Implementer.cs deleted file mode 100644 index 06e61b8..0000000 --- a/Confectionery/ConfectioneryListImplement/Models/Implementer.cs +++ /dev/null @@ -1,61 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.ViewModels; -using ConfectioneryDataModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfectioneryListImplement.Models -{ - public class Implementer : IImplementerModel - { - public int Id { get; private set; } - - public string ImplementerFIO { get; private set; } = string.Empty; - - public string Password { get; private set; } = string.Empty; - - public int WorkExperience { get; private set; } - - public int Qualification { get; private set; } - - public static Implementer? Create(ImplementerBindingModel? model) - { - if (model == null) - { - return null; - } - return new Implementer() - { - Id = model.Id, - ImplementerFIO = model.ImplementerFIO, - Password = model.Password, - WorkExperience = model.WorkExperience, - Qualification = model.Qualification - }; - } - - public void Update(ImplementerBindingModel? model) - { - if (model == null) - { - return; - } - ImplementerFIO = model.ImplementerFIO; - Password = model.Password; - WorkExperience = model.WorkExperience; - Qualification = model.Qualification; - } - - public ImplementerViewModel GetViewModel => new() - { - Id = Id, - ImplementerFIO = ImplementerFIO, - Password = Password, - WorkExperience = WorkExperience, - Qualification = Qualification - }; - } -} diff --git a/Confectionery/ConfectioneryListImplement/Models/Order.cs b/Confectionery/ConfectioneryListImplement/Models/Order.cs index b3bbac9..7463ee9 100644 --- a/Confectionery/ConfectioneryListImplement/Models/Order.cs +++ b/Confectionery/ConfectioneryListImplement/Models/Order.cs @@ -15,7 +15,6 @@ namespace ConfectioneryListImplement.Models public int Id { get; private set; } public int PastryId { get; private set; } public int ClientId { get; private set; } - public int? ImplementerId { get; private set; } public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; @@ -33,7 +32,6 @@ namespace ConfectioneryListImplement.Models Id = model.Id, PastryId = model.PastryId, ClientId = model.ClientId, - ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -49,8 +47,7 @@ namespace ConfectioneryListImplement.Models return; } Status = model.Status; - DateImplement = model.DateImplement; - ImplementerId = model.ImplementerId; + if (model.Status == OrderStatus.Готов) DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() @@ -58,7 +55,6 @@ namespace ConfectioneryListImplement.Models Id = Id, PastryId = PastryId, ClientId = ClientId, - ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status, diff --git a/Confectionery/ConfectioneryRestApi/Controllers/ImplementerController.cs b/Confectionery/ConfectioneryRestApi/Controllers/ImplementerController.cs deleted file mode 100644 index 7fd9ac6..0000000 --- a/Confectionery/ConfectioneryRestApi/Controllers/ImplementerController.cs +++ /dev/null @@ -1,107 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.BussinessLogicsContracts; -using ConfectioneryContracts.SearchModels; -using ConfectioneryContracts.ViewModels; -using ConfectioneryDataModels.Enums; -using Microsoft.AspNetCore.Mvc; - -namespace ConfectioneryRestApi.Controllers -{ - [Route("api/[controller]/[action]")] - [ApiController] - public class ImplementerController : Controller - { - private readonly ILogger _logger; - - private readonly IOrderLogic _order; - - private readonly IImplementerLogic _logic; - - public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger logger) - { - _logger = logger; - _order = order; - _logic = logic; - } - - [HttpGet] - public ImplementerViewModel? Login(string login, string password) - { - try - { - return _logic.ReadElement(new ImplementerSearchModel - { - ImplementerFIO = login, - Password = password - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Employee authorization error"); - throw; - } - } - - [HttpGet] - public List? GetNewOrders() - { - try - { - return _order.ReadList(new OrderSearchModel - { - Status = OrderStatus.Принят - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error receiving new orders"); - throw; - } - } - - [HttpGet] - public OrderViewModel? GetImplementerOrder(int implementerId) - { - try - { - return _order.ReadElement(new OrderSearchModel - { - ImplementerId = implementerId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error of receiving the current order of an implementer"); - throw; - } - } - - [HttpPost] - public void TakeOrderInWork(OrderBindingModel model) - { - try - { - _order.TakeOrderInWork(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Taking order №{Id} in work error", model.Id); - throw; - } - } - - [HttpPost] - public void FinishOrder(OrderBindingModel model) - { - try - { - _order.FinishOrder(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Finishing order №{Id} error", model.Id); - throw; - } - } - } -} diff --git a/Confectionery/ConfectioneryRestApi/Program.cs b/Confectionery/ConfectioneryRestApi/Program.cs index f50b1fa..80b4d05 100644 --- a/Confectionery/ConfectioneryRestApi/Program.cs +++ b/Confectionery/ConfectioneryRestApi/Program.cs @@ -11,12 +11,10 @@ builder.Logging.AddLog4Net("log4net.config"); // Add services to the container. builder.Services.AddTransient(); -builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/Confectionery/ConfectioneryView/FormImplementer.Designer.cs b/Confectionery/ConfectioneryView/FormImplementer.Designer.cs deleted file mode 100644 index 793e071..0000000 --- a/Confectionery/ConfectioneryView/FormImplementer.Designer.cs +++ /dev/null @@ -1,173 +0,0 @@ -namespace ConfectioneryView -{ - partial class FormImplementer - { - /// - /// 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() - { - textBoxPassword = new TextBox(); - labelPassword = new Label(); - buttonCancel = new Button(); - buttonSave = new Button(); - textBoxFIO = new TextBox(); - labelFIO = new Label(); - textBoxWorkExperience = new TextBox(); - labelWorkExperience = new Label(); - textBoxQualification = new TextBox(); - labelQualification = new Label(); - SuspendLayout(); - // - // textBoxPassword - // - textBoxPassword.Location = new Point(102, 44); - textBoxPassword.Margin = new Padding(4, 3, 4, 3); - textBoxPassword.Name = "textBoxPassword"; - textBoxPassword.Size = new Size(235, 23); - textBoxPassword.TabIndex = 15; - // - // labelPassword - // - labelPassword.AutoSize = true; - labelPassword.Location = new Point(3, 48); - labelPassword.Margin = new Padding(4, 0, 4, 0); - labelPassword.Name = "labelPassword"; - labelPassword.Size = new Size(55, 15); - labelPassword.TabIndex = 14; - labelPassword.Text = "Пароль :"; - // - // buttonCancel - // - buttonCancel.Location = new Point(242, 140); - buttonCancel.Margin = new Padding(4, 3, 4, 3); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(88, 27); - buttonCancel.TabIndex = 17; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // - // buttonSave - // - buttonSave.Location = new Point(147, 140); - buttonSave.Margin = new Padding(4, 3, 4, 3); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(88, 27); - buttonSave.TabIndex = 16; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // textBoxFIO - // - textBoxFIO.Location = new Point(102, 16); - textBoxFIO.Margin = new Padding(4, 3, 4, 3); - textBoxFIO.Name = "textBoxFIO"; - textBoxFIO.Size = new Size(235, 23); - textBoxFIO.TabIndex = 13; - // - // labelFIO - // - labelFIO.AutoSize = true; - labelFIO.Location = new Point(3, 19); - labelFIO.Margin = new Padding(4, 0, 4, 0); - labelFIO.Name = "labelFIO"; - labelFIO.Size = new Size(40, 15); - labelFIO.TabIndex = 12; - labelFIO.Text = "ФИО :"; - // - // textBoxWorkExperience - // - textBoxWorkExperience.Location = new Point(102, 74); - textBoxWorkExperience.Margin = new Padding(4, 3, 4, 3); - textBoxWorkExperience.Name = "textBoxWorkExperience"; - textBoxWorkExperience.Size = new Size(235, 23); - textBoxWorkExperience.TabIndex = 19; - // - // labelWorkExperience - // - labelWorkExperience.AutoSize = true; - labelWorkExperience.Location = new Point(3, 78); - labelWorkExperience.Margin = new Padding(4, 0, 4, 0); - labelWorkExperience.Name = "labelWorkExperience"; - labelWorkExperience.Size = new Size(85, 15); - labelWorkExperience.TabIndex = 18; - labelWorkExperience.Text = "Стаж работы :"; - // - // textBoxQualification - // - textBoxQualification.Location = new Point(102, 103); - textBoxQualification.Margin = new Padding(4, 3, 4, 3); - textBoxQualification.Name = "textBoxQualification"; - textBoxQualification.Size = new Size(235, 23); - textBoxQualification.TabIndex = 21; - // - // labelQualification - // - labelQualification.AutoSize = true; - labelQualification.Location = new Point(3, 106); - labelQualification.Margin = new Padding(4, 0, 4, 0); - labelQualification.Name = "labelQualification"; - labelQualification.Size = new Size(94, 15); - labelQualification.TabIndex = 20; - labelQualification.Text = "Квалификация :"; - // - // FormImplementer - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(350, 178); - Controls.Add(textBoxQualification); - Controls.Add(labelQualification); - Controls.Add(textBoxWorkExperience); - Controls.Add(labelWorkExperience); - Controls.Add(textBoxPassword); - Controls.Add(labelPassword); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(textBoxFIO); - Controls.Add(labelFIO); - Margin = new Padding(2, 2, 2, 2); - Name = "FormImplementer"; - Text = "Исполнитель"; - Load += FormImplementer_Load; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private TextBox textBoxPassword; - private Label labelPassword; - private Button buttonCancel; - private Button buttonSave; - private TextBox textBoxFIO; - private Label labelFIO; - private TextBox textBoxWorkExperience; - private Label labelWorkExperience; - private TextBox textBoxQualification; - private Label labelQualification; - } -} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormImplementer.cs b/Confectionery/ConfectioneryView/FormImplementer.cs deleted file mode 100644 index 4966a64..0000000 --- a/Confectionery/ConfectioneryView/FormImplementer.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Microsoft.Extensions.Logging; -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.BussinessLogicsContracts; -using ConfectioneryContracts.SearchModels; - -namespace ConfectioneryView -{ - public partial class FormImplementer : Form - { - private readonly ILogger _logger; - - private readonly IImplementerLogic _logic; - - private int? _id; - - public int Id { set { _id = value; } } - - public FormImplementer(ILogger logger, IImplementerLogic logic) - { - InitializeComponent(); - _logger = logger; - _logic = logic; - } - - private void FormImplementer_Load(object sender, EventArgs e) - { - if (_id.HasValue) - { - try - { - _logger.LogInformation("Receiving implementer"); - var view = _logic.ReadElement(new ImplementerSearchModel { Id = _id.Value }); - if (view != null) - { - textBoxFIO.Text = view.ImplementerFIO; - textBoxPassword.Text = view.Password; - textBoxQualification.Text = view.Qualification.ToString(); - textBoxWorkExperience.Text = view.WorkExperience.ToString(); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Receiving implementer error"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - - private void ButtonSave_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxFIO.Text)) - { - MessageBox.Show("Заполните ФИО исполнителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (string.IsNullOrEmpty(textBoxPassword.Text)) - { - MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (string.IsNullOrEmpty(textBoxWorkExperience.Text)) - { - MessageBox.Show("Заполните стаж работы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (string.IsNullOrEmpty(textBoxQualification.Text)) - { - MessageBox.Show("Заполните квалификацию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation("Saving implementer"); - try - { - var model = new ImplementerBindingModel - { - Id = _id ?? 0, - ImplementerFIO = textBoxFIO.Text, - Password = textBoxPassword.Text, - WorkExperience = Convert.ToInt32(textBoxWorkExperience.Text), - Qualification = Convert.ToInt32(textBoxQualification.Text) - }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Saving implementer error"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void ButtonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - } -} diff --git a/Confectionery/ConfectioneryView/FormImplementer.resx b/Confectionery/ConfectioneryView/FormImplementer.resx deleted file mode 100644 index 1af7de1..0000000 --- a/Confectionery/ConfectioneryView/FormImplementer.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormImplementers.cs b/Confectionery/ConfectioneryView/FormImplementers.cs deleted file mode 100644 index 45941ab..0000000 --- a/Confectionery/ConfectioneryView/FormImplementers.cs +++ /dev/null @@ -1,106 +0,0 @@ -using ConfectioneryContracts.BindingModels; -using ConfectioneryContracts.BussinessLogicsContracts; -using Microsoft.Extensions.Logging; - -namespace ConfectioneryView -{ - public partial class FormImplementers : Form - { - private readonly ILogger _logger; - - private readonly IImplementerLogic _logic; - - public FormImplementers(ILogger logger, IImplementerLogic logic) - { - InitializeComponent(); - _logger = logger; - _logic = logic; - } - - private void FormImplementers_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["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Implementers loading"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Implementers loading error"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void ButtonAdd_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) - { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - - private void ButtonEdit_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer 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("Deletion of implementer"); - try - { - if (!_logic.Delete(new ImplementerBindingModel { Id = id })) - { - throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Implementer deletion error"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - } - - private void ButtonUpd_Click(object sender, EventArgs e) - { - LoadData(); - } - } -} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormImplementers.designer.cs b/Confectionery/ConfectioneryView/FormImplementers.designer.cs deleted file mode 100644 index 55e6f15..0000000 --- a/Confectionery/ConfectioneryView/FormImplementers.designer.cs +++ /dev/null @@ -1,127 +0,0 @@ -namespace ConfectioneryView -{ - partial class FormImplementers - { - /// - /// 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() - { - buttonUpd = new Button(); - buttonDel = new Button(); - buttonEdit = new Button(); - buttonAdd = new Button(); - dataGridView = new DataGridView(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // buttonUpd - // - buttonUpd.Location = new Point(432, 152); - buttonUpd.Margin = new Padding(4, 3, 4, 3); - buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(88, 27); - buttonUpd.TabIndex = 4; - buttonUpd.Text = "Обновить"; - buttonUpd.UseVisualStyleBackColor = true; - buttonUpd.Click += ButtonUpd_Click; - // - // buttonDel - // - buttonDel.Location = new Point(432, 105); - buttonDel.Margin = new Padding(4, 3, 4, 3); - buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(88, 27); - buttonDel.TabIndex = 3; - buttonDel.Text = "Удалить"; - buttonDel.UseVisualStyleBackColor = true; - buttonDel.Click += ButtonDel_Click; - // - // buttonEdit - // - buttonEdit.Location = new Point(432, 58); - buttonEdit.Margin = new Padding(4, 3, 4, 3); - buttonEdit.Name = "buttonEdit"; - buttonEdit.Size = new Size(88, 27); - buttonEdit.TabIndex = 2; - buttonEdit.Text = "Изменить"; - buttonEdit.UseVisualStyleBackColor = true; - buttonEdit.Click += ButtonEdit_Click; - // - // buttonAdd - // - buttonAdd.Location = new Point(432, 14); - buttonAdd.Margin = new Padding(4, 3, 4, 3); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(88, 27); - buttonAdd.TabIndex = 1; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.BackgroundColor = SystemColors.ControlLightLight; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Left; - dataGridView.Location = new Point(0, 0); - dataGridView.Margin = new Padding(4, 3, 4, 3); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(408, 360); - dataGridView.TabIndex = 0; - // - // FormImplementers - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(541, 360); - Controls.Add(buttonUpd); - Controls.Add(buttonDel); - Controls.Add(buttonEdit); - Controls.Add(buttonAdd); - Controls.Add(dataGridView); - Margin = new Padding(4, 3, 4, 3); - Name = "FormImplementers"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Исполнители"; - Load += FormImplementers_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Button buttonUpd; - private Button buttonDel; - private Button buttonEdit; - private Button buttonAdd; - private DataGridView dataGridView; - } -} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormImplementers.resx b/Confectionery/ConfectioneryView/FormImplementers.resx deleted file mode 100644 index af32865..0000000 --- a/Confectionery/ConfectioneryView/FormImplementers.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormMain.Designer.cs b/Confectionery/ConfectioneryView/FormMain.Designer.cs index 85fca5f..f1d6d1f 100644 --- a/Confectionery/ConfectioneryView/FormMain.Designer.cs +++ b/Confectionery/ConfectioneryView/FormMain.Designer.cs @@ -33,14 +33,14 @@ КомпонентыToolStripMenuItem = new ToolStripMenuItem(); КондитерскиеИзделияToolStripMenuItem = new ToolStripMenuItem(); клиентыToolStripMenuItem = new ToolStripMenuItem(); - ИсполнителиToolStripMenuItem = new ToolStripMenuItem(); отчетыToolStripMenuItem = new ToolStripMenuItem(); списокКондитерскихИзделийToolStripMenuItem = new ToolStripMenuItem(); компонентыПоКондитерскимИзделиямToolStripMenuItem = new ToolStripMenuItem(); списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); - ЗапускРаботToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonUpd = new Button(); menuStrip.SuspendLayout(); @@ -50,17 +50,17 @@ // menuStrip // menuStrip.ImageScalingSize = new Size(20, 20); - menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, ЗапускРаботToolStripMenuItem }); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; menuStrip.Padding = new Padding(7, 3, 0, 3); - menuStrip.Size = new Size(1332, 30); + menuStrip.Size = new Size(1344, 30); menuStrip.TabIndex = 0; menuStrip.Text = "menuStrip1"; // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, КондитерскиеИзделияToolStripMenuItem, клиентыToolStripMenuItem, ИсполнителиToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, КондитерскиеИзделияToolStripMenuItem, клиентыToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Text = "Справочники"; @@ -86,13 +86,6 @@ клиентыToolStripMenuItem.Text = "Клиенты"; клиентыToolStripMenuItem.Click += КлиентыToolStripMenuItem_Click; // - // ИсполнителиToolStripMenuItem - // - ИсполнителиToolStripMenuItem.Name = "ИсполнителиToolStripMenuItem"; - ИсполнителиToolStripMenuItem.Size = new Size(251, 26); - ИсполнителиToolStripMenuItem.Text = "Исполнители"; - ИсполнителиToolStripMenuItem.Click += ИсполнителиToolStripMenuItem_Click; - // // отчетыToolStripMenuItem // отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКондитерскихИзделийToolStripMenuItem, компонентыПоКондитерскимИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem }); @@ -121,13 +114,6 @@ списокЗаказовToolStripMenuItem.Text = "Список заказов"; списокЗаказовToolStripMenuItem.Click += СписокЗаказовToolStripMenuItem_Click; // - // ЗапускРаботToolStripMenuItem - // - ЗапускРаботToolStripMenuItem.Name = "ЗапускРаботToolStripMenuItem"; - ЗапускРаботToolStripMenuItem.Size = new Size(114, 24); - ЗапускРаботToolStripMenuItem.Text = "Запуск работ"; - ЗапускРаботToolStripMenuItem.Click += ЗапускРаботToolStripMenuItem_Click; - // // dataGridView // dataGridView.AllowUserToAddRows = false; @@ -137,12 +123,12 @@ dataGridView.Margin = new Padding(3, 4, 3, 4); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 51; - dataGridView.Size = new Size(1069, 408); + dataGridView.Size = new Size(1061, 408); dataGridView.TabIndex = 1; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(1092, 156); + buttonCreateOrder.Location = new Point(1085, 70); buttonCreateOrder.Margin = new Padding(3, 4, 3, 4); buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Size = new Size(208, 36); @@ -151,9 +137,31 @@ buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Click += buttonCreateOrder_Click; // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Location = new Point(1085, 142); + buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(210, 35); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Location = new Point(1085, 218); + buttonOrderReady.Margin = new Padding(3, 4, 3, 4); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(208, 37); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += buttonOrderReady_Click; + // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(1092, 220); + buttonIssuedOrder.Location = new Point(1085, 292); buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4); buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonIssuedOrder.Size = new Size(208, 36); @@ -164,7 +172,7 @@ // // buttonUpd // - buttonUpd.Location = new Point(1092, 282); + buttonUpd.Location = new Point(1087, 366); buttonUpd.Margin = new Padding(3, 4, 3, 4); buttonUpd.Name = "buttonUpd"; buttonUpd.Size = new Size(208, 39); @@ -177,9 +185,11 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1332, 443); + ClientSize = new Size(1344, 443); Controls.Add(buttonUpd); Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); Controls.Add(buttonCreateOrder); Controls.Add(dataGridView); Controls.Add(menuStrip); @@ -203,6 +213,8 @@ private ToolStripMenuItem КондитерскиеИзделияToolStripMenuItem; private DataGridView dataGridView; private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonUpd; private ToolStripMenuItem отчетыToolStripMenuItem; @@ -210,8 +222,5 @@ private ToolStripMenuItem компонентыПоКондитерскимИзделиямToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem; - private ToolStripMenuItem ИсполнителиToolStripMenuItem; - private ToolStripMenuItem ЗапускРаботToolStripMenuItem; - } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormMain.cs b/Confectionery/ConfectioneryView/FormMain.cs index 3b6ddb6..18056bc 100644 --- a/Confectionery/ConfectioneryView/FormMain.cs +++ b/Confectionery/ConfectioneryView/FormMain.cs @@ -18,14 +18,12 @@ namespace ConfectioneryView private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; - private readonly IWorkProcess _workProcess; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; _reportLogic = reportLogic; - _workProcess = workProcess; } private void FormMain_Load(object sender, EventArgs e) @@ -44,8 +42,6 @@ namespace ConfectioneryView dataGridView.Columns["PastryName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["ImplementerId"].Visible = false; - dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -120,6 +116,52 @@ namespace ConfectioneryView } } + private void buttonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void buttonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonIssuedOrder_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) @@ -148,20 +190,5 @@ namespace ConfectioneryView { LoadData(); } - - private void ИсполнителиToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - if (service is FormImplementers form) - { - form.ShowDialog(); - } - } - - private void ЗапускРаботToolStripMenuItem_Click(object sender, EventArgs e) - { - _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); - MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); - } } } diff --git a/Confectionery/ConfectioneryView/Program.cs b/Confectionery/ConfectioneryView/Program.cs index faf3a41..a5fc304 100644 --- a/Confectionery/ConfectioneryView/Program.cs +++ b/Confectionery/ConfectioneryView/Program.cs @@ -40,15 +40,12 @@ namespace ConfectioneryView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -62,8 +59,6 @@ namespace ConfectioneryView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); }