From 1d73cccb0dbb8a68b89526e6d1b19a5bd4741fd9 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 4 Apr 2023 15:05:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D1=8B=D0=B5=20=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F.=20=D0=AD=D1=82=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BF=D0=B5=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ImplementerController.cs | 16 ++++----- .../BlackmithWorkshopRestApi/Program.cs | 4 +-- .../BlacksmithWorkshop - Backup.csproj | 33 +++++++++++++++++++ .../BusinessLogic/WorkModeling.cs | 12 +++---- .../BindingModels/ImplementerBindingModel.cs | 22 +++++++++++++ .../IImplementerLogic.cs | 23 +++++++++++++ .../BusinessLogicsContracts/IWorkProcess.cs | 2 +- .../ViewModels/ImplementerViewModel.cs | 27 +++++++++++++++ .../Models/IImplementerModel.cs | 5 ++- 9 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop - Backup.csproj create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs rename BlacksmithWorkshop/{BlacksmithWorkshopDatabaseImplement => BlacksmithWorkshopDataModels}/Models/IImplementerModel.cs (74%) diff --git a/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs b/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs index 6dc96c7..29e7a7a 100644 --- a/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs +++ b/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs @@ -8,15 +8,15 @@ namespace BlacksmithWorkshopRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] - public class ImplementerController : Controller + public class ClientController : Controller { private readonly ILogger _logger; private readonly IOrderLogic _order; - private readonly IImplementerLogic _logic; + private readonly IClientLogic _logic; - public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger logger) + public ClientController(IOrderLogic order, IClientLogic logic, ILogger logger) { _logger = logger; _order = order; @@ -24,13 +24,13 @@ namespace BlacksmithWorkshopRestApi.Controllers } [HttpGet] - public ImplementerViewModel? Login(string login, string password) + public ClientViewModel? Login(string login, string password) { try { - return _logic.ReadElement(new ImplementerSearchModel + return _logic.ReadElement(new ClientSearchModel { - ImplementerFIO = login, + ClientFIO = login, Password = password }); } @@ -61,13 +61,13 @@ namespace BlacksmithWorkshopRestApi.Controllers } [HttpGet] - public OrderViewModel? GetImplementerOrder(int implementerId) + public OrderViewModel? GetClientOrder(int implementerId) { try { return _order.ReadElement(new OrderSearchModel { - ImplementerId = implementerId + ClientId = implementerId }); } catch (Exception ex) diff --git a/BlacksmithWorkshop/BlackmithWorkshopRestApi/Program.cs b/BlacksmithWorkshop/BlackmithWorkshopRestApi/Program.cs index 017ef90..4fc3bb6 100644 --- a/BlacksmithWorkshop/BlackmithWorkshopRestApi/Program.cs +++ b/BlacksmithWorkshop/BlackmithWorkshopRestApi/Program.cs @@ -14,12 +14,12 @@ builder.Logging.AddLog4Net("log4net.config"); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop - Backup.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop - Backup.csproj new file mode 100644 index 0000000..6707010 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop - Backup.csproj @@ -0,0 +1,33 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs index 624637f..fb2486b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs @@ -26,14 +26,14 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic _rnd = new Random(1000); } - public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) + public void DoWork(IClientLogic implementerLogic, IOrderLogic orderLogic) { _orderLogic = orderLogic; var implementers = implementerLogic.ReadList(null); if (implementers == null) { - _logger.LogWarning("DoWork. Implementers is null"); + _logger.LogWarning("DoWork. Clients is null"); return; } @@ -56,7 +56,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic } // Иммитация работы исполнителя - private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) + private async Task WorkerWorkAsync(ClientViewModel implementer, List orders) { if (_orderLogic == null || implementer == null) { @@ -77,7 +77,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = order.Id, - ImplementerId = implementer.Id + ClientId = implementer.Id }); // делаем работу @@ -108,7 +108,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic } //Ищем заказ, которые уже в работе (вдруг исполнителя прервали) - private async Task RunOrderInWork(ImplementerViewModel implementer) + private async Task RunOrderInWork(ClientViewModel implementer) { if (_orderLogic == null || implementer == null) { @@ -119,7 +119,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic { var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel { - ImplementerId = implementer.Id, + ClientId = implementer.Id, Status = OrderStatus.Выполняется })); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..e26ac44 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,22 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.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/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs new file mode 100644 index 0000000..da12fb6 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -0,0 +1,23 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BusinessLogicsContracts +{ + 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/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs index 812fdaf..0d72949 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs @@ -10,6 +10,6 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts public interface IWorkProcess { // Запуск работ - void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic); + void DoWork(IClientLogic implementerLogic, IOrderLogic orderLogic); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..2554098 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,27 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.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/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/IImplementerModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IImplementerModel.cs similarity index 74% rename from BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/IImplementerModel.cs rename to BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IImplementerModel.cs index f00bc19..9ac63d5 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/IImplementerModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IImplementerModel.cs @@ -1,11 +1,10 @@ -using BlacksmithWorkshopDataModels; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BlacksmithWorkshopDatabaseImplement.Models +namespace BlacksmithWorkshopDataModels.Models { //модель исполнителя public interface IImplementerModel : IId