From 805e5e9dab6ce64736c0991acba16845d55dec16 Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Mon, 22 Apr 2024 20:09:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BE=D0=B3=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FlowerShopBusinessLogic/ClientLogic.cs | 4 +- FlowerShopBusinessLogic/ImplementerLogic.cs | 126 ++++++++++++++++ FlowerShopBusinessLogic/OrderLogic.cs | 35 ++++- FlowerShopBusinessLogic/WorkProcess.cs | 137 ++++++++++++++++++ .../BindingModels/ImplementerBindingModel.cs | 18 +++ .../BindingModels/OrderBindingModel.cs | 3 +- .../IImplementerLogic.cs | 20 +++ .../BusinessLogicsContracts/IOrderLogic.cs | 3 +- .../BusinessLogicsContracts/IWorkProcess.cs | 13 ++ .../SearchModels/ImplementerSearchModel.cs | 16 ++ .../SearchModels/OrderSearchModel.cs | 7 +- .../StoragesContracts/IImplementerStorage.cs | 21 +++ .../ViewModels/ImplementerViewModel.cs | 23 +++ .../ViewModels/OrderViewModel.cs | 7 +- FlowerShopDataModels/IImplementerModel.cs | 16 ++ FlowerShopDatabaseImplement/Implemeter.cs | 63 ++++++++ FlowerShopFileImplement/DataFileSingleton.cs | 15 +- FlowerShopFileImplement/FlowerStorage.cs | 16 +- FlowerShopFileImplement/Implementer.cs | 78 ++++++++++ FlowerShopFileImplement/ImplementerStorage.cs | 84 +++++++++++ FlowerShopFileImplement/Order.cs | 15 +- FlowerShopFileImplement/OrderStorage.cs | 69 +++++---- FlowerShopListImplement/DataListSingleton.cs | 3 +- FlowerShopListImplement/Implementer.cs | 54 +++++++ FlowerShopListImplement/ImplemeterStorage.cs | 103 +++++++++++++ FlowerShopListImplement/Order.cs | 13 +- FlowerShopListImplement/OrderStorage.cs | 53 ++++--- 27 files changed, 914 insertions(+), 101 deletions(-) create mode 100644 FlowerShopBusinessLogic/ImplementerLogic.cs create mode 100644 FlowerShopBusinessLogic/WorkProcess.cs create mode 100644 FlowerShopContracts/BindingModels/ImplementerBindingModel.cs create mode 100644 FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs create mode 100644 FlowerShopContracts/BusinessLogicsContracts/IWorkProcess.cs create mode 100644 FlowerShopContracts/SearchModels/ImplementerSearchModel.cs create mode 100644 FlowerShopContracts/StoragesContracts/IImplementerStorage.cs create mode 100644 FlowerShopContracts/ViewModels/ImplementerViewModel.cs create mode 100644 FlowerShopDataModels/IImplementerModel.cs create mode 100644 FlowerShopDatabaseImplement/Implemeter.cs create mode 100644 FlowerShopFileImplement/Implementer.cs create mode 100644 FlowerShopFileImplement/ImplementerStorage.cs create mode 100644 FlowerShopListImplement/Implementer.cs create mode 100644 FlowerShopListImplement/ImplemeterStorage.cs diff --git a/FlowerShopBusinessLogic/ClientLogic.cs b/FlowerShopBusinessLogic/ClientLogic.cs index 09fbaff..d734843 100644 --- a/FlowerShopBusinessLogic/ClientLogic.cs +++ b/FlowerShopBusinessLogic/ClientLogic.cs @@ -16,10 +16,10 @@ namespace FlowerShopBusinessLogic.BusinessLogic { private readonly ILogger _logger; private readonly IClientStorage _clientStorage; - public ClientLogic(ILogger logger, IClientStorage componentStorage) + public ClientLogic(ILogger logger, IClientStorage clientStorage) { _logger = logger; - _clientStorage = componentStorage; + _clientStorage = clientStorage; } public List? ReadList(ClientSearchModel? model) { diff --git a/FlowerShopBusinessLogic/ImplementerLogic.cs b/FlowerShopBusinessLogic/ImplementerLogic.cs new file mode 100644 index 0000000..952d093 --- /dev/null +++ b/FlowerShopBusinessLogic/ImplementerLogic.cs @@ -0,0 +1,126 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.BusinessLogicsContracts; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.StoragesContracts; +using FlowerShopContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopBusinessLogic.BusinessLogic +{ + 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:{ClientFIO}. 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 ArgumentException("Квалификация меньше 0", nameof(model.Qualification)); + } + _logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}." + + "Password:{ Password}. WorkExperience:{ WorkExperience}. Qualification:{ Qualification}. Id: { Id} ", + model.ImplementerFIO, model.Password, model.WorkExperience, model.Qualification, model.Id); + var element = _implementerStorage.GetElement(new ImplementerSearchModel + { + ImplementerFIO = model.ImplementerFIO, + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Исполнитель с таким ФИО уже есть"); + } + } + } +} diff --git a/FlowerShopBusinessLogic/OrderLogic.cs b/FlowerShopBusinessLogic/OrderLogic.cs index c19d04d..4493764 100644 --- a/FlowerShopBusinessLogic/OrderLogic.cs +++ b/FlowerShopBusinessLogic/OrderLogic.cs @@ -17,14 +17,30 @@ namespace FlowerShopBusinessLogic.BusinessLogic { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; + static readonly object locker = new object(); - public OrderLogic(ILogger logger, IOrderStorage orderStorage) + public OrderLogic(ILogger logger, IOrderStorage orderStorage) { _logger = logger; _orderStorage = orderStorage; } - - public List? ReadList(OrderSearchModel? model) + 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 List? ReadList(OrderSearchModel? model) { _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); var list = model == null ? _orderStorage.GetFullList() : @@ -53,7 +69,7 @@ namespace FlowerShopBusinessLogic.BusinessLogic public bool ChangeStatus(OrderBindingModel model, OrderStatus status) { - CheckModel(model); + CheckModel(model,false); var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); if (element == null) { @@ -67,14 +83,19 @@ namespace FlowerShopBusinessLogic.BusinessLogic } model.Status = status; if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; - _orderStorage.Update(model); + if (element.ImplementerId.HasValue) + model.ImplementerId = element.ImplementerId; + _orderStorage.Update(model); return true; } public bool TakeOrderInWork(OrderBindingModel model) { - return ChangeStatus(model, OrderStatus.Выполняется); - } + lock (locker) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + } public bool FinishOrder(OrderBindingModel model) { diff --git a/FlowerShopBusinessLogic/WorkProcess.cs b/FlowerShopBusinessLogic/WorkProcess.cs new file mode 100644 index 0000000..03367fa --- /dev/null +++ b/FlowerShopBusinessLogic/WorkProcess.cs @@ -0,0 +1,137 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.BusinessLogicsContracts; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopBusinessLogic +{ + public class WorkProcess : IWorkProcess + { + private readonly ILogger _logger; + private readonly Random _rnd; + private IOrderLogic? _orderLogic; + public WorkProcess(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 + }); + } + // кто-то мог уже перехватить заказ, игнорируем ошибку + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + // заканчиваем выполнение имитации в случае иной ошибки + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + }); + } + /// Ищем заказ, которые уже в работе (вдруг исполнителя прервали) + 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/FlowerShopContracts/BindingModels/ImplementerBindingModel.cs b/FlowerShopContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..29b90cd --- /dev/null +++ b/FlowerShopContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,18 @@ +using FlowerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopContracts.BindingModels +{ + public class ImplementerBindingModel : IImplementerModel + { + public int Id { get; set; } + public string ImplementerFIO { get; set; } = string.Empty; + public int WorkExperience { get; set; } = 0; + public int Qualification { get; set; } = 0; + public string Password { get; set; } = string.Empty; + } +} diff --git a/FlowerShopContracts/BindingModels/OrderBindingModel.cs b/FlowerShopContracts/BindingModels/OrderBindingModel.cs index 64006fc..adedd7c 100644 --- a/FlowerShopContracts/BindingModels/OrderBindingModel.cs +++ b/FlowerShopContracts/BindingModels/OrderBindingModel.cs @@ -18,6 +18,7 @@ namespace FlowerShopContracts.BindingModels public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } public int ClientId { get; set; } + public int? ImplementerId { get; set; } = null; - } + } } diff --git a/FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs b/FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs new file mode 100644 index 0000000..934e7e5 --- /dev/null +++ b/FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -0,0 +1,20 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopContracts.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/FlowerShopContracts/BusinessLogicsContracts/IOrderLogic.cs b/FlowerShopContracts/BusinessLogicsContracts/IOrderLogic.cs index 298066a..27f4e33 100644 --- a/FlowerShopContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/FlowerShopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -16,5 +16,6 @@ namespace FlowerShopContracts.BusinessLogicsContracts bool TakeOrderInWork(OrderBindingModel model); bool FinishOrder(OrderBindingModel model); bool DeliveryOrder(OrderBindingModel model); - } + OrderViewModel? ReadElement(OrderSearchModel model); + } } diff --git a/FlowerShopContracts/BusinessLogicsContracts/IWorkProcess.cs b/FlowerShopContracts/BusinessLogicsContracts/IWorkProcess.cs new file mode 100644 index 0000000..4ab1841 --- /dev/null +++ b/FlowerShopContracts/BusinessLogicsContracts/IWorkProcess.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopContracts.BusinessLogicsContracts +{ + public interface IWorkProcess + { + void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic); + } +} diff --git a/FlowerShopContracts/SearchModels/ImplementerSearchModel.cs b/FlowerShopContracts/SearchModels/ImplementerSearchModel.cs new file mode 100644 index 0000000..582f4c7 --- /dev/null +++ b/FlowerShopContracts/SearchModels/ImplementerSearchModel.cs @@ -0,0 +1,16 @@ +using FlowerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopContracts.SearchModels +{ + public class ImplementerSearchModel + { + public int? Id { get; set; } + public string? ImplementerFIO { get; set; } = string.Empty; + public string? Password { get; set; } = string.Empty; + } +} diff --git a/FlowerShopContracts/SearchModels/OrderSearchModel.cs b/FlowerShopContracts/SearchModels/OrderSearchModel.cs index 7737f3f..93af94f 100644 --- a/FlowerShopContracts/SearchModels/OrderSearchModel.cs +++ b/FlowerShopContracts/SearchModels/OrderSearchModel.cs @@ -1,4 +1,5 @@ -using System; +using FlowerShopDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,6 +13,8 @@ namespace FlowerShopContracts.SearchModels public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } public int? ClientId { get; set; } + public int? ImplementerId { get; set; } + public OrderStatus? Status { get; set; } - } + } } diff --git a/FlowerShopContracts/StoragesContracts/IImplementerStorage.cs b/FlowerShopContracts/StoragesContracts/IImplementerStorage.cs new file mode 100644 index 0000000..b84cc7d --- /dev/null +++ b/FlowerShopContracts/StoragesContracts/IImplementerStorage.cs @@ -0,0 +1,21 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopContracts.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/FlowerShopContracts/ViewModels/ImplementerViewModel.cs b/FlowerShopContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..7c43f92 --- /dev/null +++ b/FlowerShopContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,23 @@ +using FlowerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopContracts.ViewModels +{ + public class ImplementerViewModel : IImplementerModel + { + public int Id { get; set; } + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; } = string.Empty; + [DisplayName("Стаж работы")] + public int WorkExperience { get; set; } = 0; + [DisplayName("Квалификация")] + public int Qualification { get; set; } = 0; + [DisplayName("Пароль")] + public string Password { get; set; } = string.Empty; + } +} diff --git a/FlowerShopContracts/ViewModels/OrderViewModel.cs b/FlowerShopContracts/ViewModels/OrderViewModel.cs index 6044b89..05602be 100644 --- a/FlowerShopContracts/ViewModels/OrderViewModel.cs +++ b/FlowerShopContracts/ViewModels/OrderViewModel.cs @@ -14,9 +14,12 @@ namespace FlowerShopContracts.ViewModels [DisplayName("Номер")] public int Id { get; set; } public int FlowerId { get; set; } - [DisplayName("Изделие")] + public int? ImplementerId { get; set; } = null; + [DisplayName("Изделие")] public string FlowerName { get; set; } = string.Empty; - [DisplayName("Количество")] + [DisplayName("Исполнитель")] + public string ImplementerFIO { get; set; } = string.Empty; + [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] public double Sum { get; set; } diff --git a/FlowerShopDataModels/IImplementerModel.cs b/FlowerShopDataModels/IImplementerModel.cs new file mode 100644 index 0000000..db5feaf --- /dev/null +++ b/FlowerShopDataModels/IImplementerModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopDataModels.Models +{ + public interface IImplementerModel : IId + { + string ImplementerFIO { get; } + string Password { get; } + int WorkExperience { get; } + int Qualification { get; } + } +} diff --git a/FlowerShopDatabaseImplement/Implemeter.cs b/FlowerShopDatabaseImplement/Implemeter.cs new file mode 100644 index 0000000..a029132 --- /dev/null +++ b/FlowerShopDatabaseImplement/Implemeter.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels; + +namespace FlowerShopDatabaseImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + [Required] + public string ImplementerFIO { get; private set; } = string.Empty; + [Required] + public string Password { get; set; } = string.Empty; + [Required] + public int Qualification { get; set; } = 0; + [Required] + public int WorkExperience { get; set; } = 0; + [ForeignKey("ImplementerId")] + public virtual List Orders { get; set; } = + new(); + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + return new() + { + Id = model.Id, + Password = model.Password, + Qualification = model.Qualification, + ImplementerFIO = model.ImplementerFIO, + WorkExperience = model.WorkExperience, + }; + } + + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + Password = model.Password; + Qualification = model.Qualification; + ImplementerFIO = model.ImplementerFIO; + WorkExperience = model.WorkExperience; + } + + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + Password = Password, + Qualification = Qualification, + ImplementerFIO = ImplementerFIO, + WorkExperience = WorkExperience, + }; + } +} diff --git a/FlowerShopFileImplement/DataFileSingleton.cs b/FlowerShopFileImplement/DataFileSingleton.cs index 80175a7..3e66795 100644 --- a/FlowerShopFileImplement/DataFileSingleton.cs +++ b/FlowerShopFileImplement/DataFileSingleton.cs @@ -10,13 +10,14 @@ internal class DataFileSingleton private readonly string OrderFileName = "Order.xml"; private readonly string FlowerFileName = "Product.xml"; private readonly string ClientFileName = "Client.xml"; - - public List Components { get; private set; } + private readonly string ImplementerFileName = "Implementer.xml"; + public List Components { get; private set; } public List Orders { get; private set; } public List Flowers { get; private set; } public List Clients { get; private set; } + public List Implementers { get; private set; } - public static DataFileSingleton GetInstance() + public static DataFileSingleton GetInstance() { if (instance == null) { @@ -24,7 +25,9 @@ internal class DataFileSingleton } return instance; } - public void SaveComponents() => SaveData(Components, ComponentFileName, + public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, + "Implementers", x => x.GetXElement); + public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); public void SaveFlowers() => SaveData(Flowers, FlowerFileName, "Flowers", x => x.GetXElement); @@ -37,8 +40,8 @@ internal class DataFileSingleton Flowers = LoadData(FlowerFileName, "Flower", x => Flower.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) { if (File.Exists(filename)) diff --git a/FlowerShopFileImplement/FlowerStorage.cs b/FlowerShopFileImplement/FlowerStorage.cs index c06d89a..e1ac660 100644 --- a/FlowerShopFileImplement/FlowerStorage.cs +++ b/FlowerShopFileImplement/FlowerStorage.cs @@ -67,25 +67,25 @@ namespace FlowerShopFileImplement.Implements public FlowerViewModel? Update(FlowerBindingModel model) { - var iceCream = source.Flowers.FirstOrDefault(x => x.Id == + var flower = source.Flowers.FirstOrDefault(x => x.Id == model.Id); - if (iceCream == null) + if (flower == null) { return null; } - iceCream.Update(model); + flower.Update(model); source.SaveFlowers(); - return iceCream.GetViewModel; + return flower.GetViewModel; } public FlowerViewModel? Delete(FlowerBindingModel model) { - var iceCream = source.Flowers.FirstOrDefault(x => x.Id == + var flower = source.Flowers.FirstOrDefault(x => x.Id == model.Id); - if (iceCream != null) + if (flower != null) { - source.Flowers.Remove(iceCream); + source.Flowers.Remove(flower); source.SaveFlowers(); - return iceCream.GetViewModel; + return flower.GetViewModel; } return null; } diff --git a/FlowerShopFileImplement/Implementer.cs b/FlowerShopFileImplement/Implementer.cs new file mode 100644 index 0000000..fe608a9 --- /dev/null +++ b/FlowerShopFileImplement/Implementer.cs @@ -0,0 +1,78 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace FlowerShopFileImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + public string ImplementerFIO { get; private set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public int Qualification { get; set; } = 0; + public int WorkExperience { get; set; } = 0; + 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 + }; + 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, + Qualification = Convert.ToInt32(element.Element("Qualification")!.Value), + WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value) + }; + } + + public XElement GetXElement => new("Implementer", + new XAttribute("Id", Id), + new XElement("ImplementerFIO", ImplementerFIO), + new XElement("Password", Password), + new XElement("Qualification", Qualification.ToString()), + new XElement("WorkExperience", WorkExperience.ToString()) + ); + } +} diff --git a/FlowerShopFileImplement/ImplementerStorage.cs b/FlowerShopFileImplement/ImplementerStorage.cs new file mode 100644 index 0000000..f63c112 --- /dev/null +++ b/FlowerShopFileImplement/ImplementerStorage.cs @@ -0,0 +1,84 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.StoragesContracts; +using FlowerShopContracts.ViewModels; +using FlowerShopFileImplement.Models; +using FlowerShopFileImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopFileImplement.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) && string.IsNullOrEmpty(model.Password)) + { + return new(); + } + return source.Implementers + .Where(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO.Contains(model.ImplementerFIO)) && + (string.IsNullOrEmpty(model.Password) || x.Password.Contains(model.Password))) + .Select(x => x.GetViewModel) + .ToList(); + } + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + return source.Implementers + .FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) && + (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) + ?.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(rec => rec.Id == model.Id); + if (element != null) + { + source.Implementers.Remove(element); + source.SaveImplementers(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/FlowerShopFileImplement/Order.cs b/FlowerShopFileImplement/Order.cs index fb2ffc7..57117d1 100644 --- a/FlowerShopFileImplement/Order.cs +++ b/FlowerShopFileImplement/Order.cs @@ -16,9 +16,10 @@ namespace FlowerShopFileImplement.Models public DateTime DateCreate { get; private set; } public DateTime? DateImplement { get; private set; } public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } = null; - public static Order? Create(OrderBindingModel model) + public static Order? Create(OrderBindingModel model) { if (model == null) { @@ -34,8 +35,9 @@ namespace FlowerShopFileImplement.Models DateCreate = model.DateCreate, DateImplement = model.DateImplement, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, - }; + }; } public static Order? Create(XElement element) { @@ -47,7 +49,8 @@ namespace FlowerShopFileImplement.Models { Id = Convert.ToInt32(element.Attribute("Id")!.Value), FlowerId = Convert.ToInt32(element.Element("FlowerId")!.Value), - Count = Convert.ToInt32(element.Element("Count")!.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.ToString()), DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value), @@ -71,7 +74,8 @@ namespace FlowerShopFileImplement.Models Count = Count, Sum = Sum, ClientId = ClientId, - Status = Status, + ImplementerId = ImplementerId, + Status = Status, DateCreate = DateCreate, DateImplement = DateImplement, }; @@ -83,7 +87,8 @@ namespace FlowerShopFileImplement.Models new XElement("Status", Status.ToString()), new XElement("DateCreate", DateCreate.ToString()), new XElement("ClientId", ClientId), - new XElement("DateImplement", DateImplement.ToString()) + new XElement("ImplementerId", ImplementerId), + new XElement("DateImplement", DateImplement.ToString()) ); } diff --git a/FlowerShopFileImplement/OrderStorage.cs b/FlowerShopFileImplement/OrderStorage.cs index 09c6463..8afadbe 100644 --- a/FlowerShopFileImplement/OrderStorage.cs +++ b/FlowerShopFileImplement/OrderStorage.cs @@ -23,7 +23,7 @@ namespace FlowerShopFileImplement.Implements public List GetFullList() { return source.Orders - .Select(x => AccessFlowerStorage(x.GetViewModel)) + .Select(x => AccessStorage(x.GetViewModel)) .ToList(); } @@ -33,13 +33,18 @@ namespace FlowerShopFileImplement.Implements { return new(); } - return source.Orders - .Where(x => ((!model.Id.HasValue || x.Id == model.Id) && - (!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) && - (!model.DateTo.HasValue || x.DateCreate <= model.DateTo) && - (!model.ClientId.HasValue || x.ClientId == model.ClientId))) - .Select(x => AccessFlowerStorage(x.GetViewModel)) - .ToList(); + return source.Orders.Where(x => ( + (!model.Id.HasValue || x.Id == model.Id) && + (!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) && + (!model.DateTo.HasValue || x.DateCreate <= model.DateTo) + && + (!model.ClientId.HasValue || x.ClientId == model.ClientId) + && + (!model.Status.HasValue || x.Status == model.Status) + ) + ) + .Select(x => AccessStorage(x.GetViewModel)) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) @@ -48,8 +53,12 @@ namespace FlowerShopFileImplement.Implements { return null; } - return AccessFlowerStorage(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel); - } + return AccessStorage(source.Orders + .FirstOrDefault( + x => ((model.Id.HasValue && x.Id == model.Id) || + (model.ImplementerId.HasValue && model.Status.HasValue && + x.ImplementerId == model.ImplementerId && x.Status == model.Status)))?.GetViewModel ?? new()); + } public OrderViewModel? Insert(OrderBindingModel model) { @@ -61,7 +70,7 @@ namespace FlowerShopFileImplement.Implements } source.Orders.Add(newOrder); source.SaveOrders(); - return AccessFlowerStorage(newOrder.GetViewModel); + return AccessStorage(newOrder.GetViewModel); } public OrderViewModel? Update(OrderBindingModel model) @@ -73,7 +82,7 @@ namespace FlowerShopFileImplement.Implements } order.Update(model); source.SaveOrders(); - return AccessFlowerStorage(order.GetViewModel); + return AccessStorage(order.GetViewModel); } public OrderViewModel? Delete(OrderBindingModel model) { @@ -83,35 +92,25 @@ namespace FlowerShopFileImplement.Implements { source.Orders.Remove(element); source.SaveOrders(); - return AccessFlowerStorage(element.GetViewModel); + return AccessStorage(element.GetViewModel); } return null; } - public OrderViewModel AccessFlowerStorage(OrderViewModel model) + public OrderViewModel AccessStorage(OrderViewModel model) { if (model == null) return null; - foreach (var flower in source.Flowers) - { - if (flower.Id == model.FlowerId) - { - model.FlowerName = flower.FlowerName; - break; - } - } - return model; - } - - public OrderViewModel AccessClientStorage(OrderViewModel model) - { - if (model == null) - return null; - var client = source.Clients.FirstOrDefault(x => x.Id == model.Id); - if (client != null) - model.ClientFIO = client.ClientFIO; - return model; - } - + var flower = source.Flowers.FirstOrDefault(x => x.Id == model.Id); + var client = source.Clients.FirstOrDefault(x => x.Id == model.Id); + var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId); + if (flower != null) + model.FlowerName = flower.FlowerName; + if (client != null) + model.ClientFIO = client.ClientFIO; + if (implementer != null) + model.ImplementerFIO = implementer.ImplementerFIO; + return model; + } } } diff --git a/FlowerShopListImplement/DataListSingleton.cs b/FlowerShopListImplement/DataListSingleton.cs index 35a183a..fc19b19 100644 --- a/FlowerShopListImplement/DataListSingleton.cs +++ b/FlowerShopListImplement/DataListSingleton.cs @@ -14,8 +14,9 @@ namespace FlowerShopListImplement public List Orders { get; set; } public List Flowers { get; set; } public List Clients { get; set; } + public List Implementers { get; set; } - private DataListSingleton() + private DataListSingleton() { Components = new List(); Orders = new List(); diff --git a/FlowerShopListImplement/Implementer.cs b/FlowerShopListImplement/Implementer.cs new file mode 100644 index 0000000..cfafe9b --- /dev/null +++ b/FlowerShopListImplement/Implementer.cs @@ -0,0 +1,54 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopListImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + public string ImplementerFIO { get; private set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public int WorkExperience { get; set; } = 0; + public int Qualification { get; set; } = 0; + 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/FlowerShopListImplement/ImplemeterStorage.cs b/FlowerShopListImplement/ImplemeterStorage.cs new file mode 100644 index 0000000..94bca38 --- /dev/null +++ b/FlowerShopListImplement/ImplemeterStorage.cs @@ -0,0 +1,103 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.StoragesContracts; +using FlowerShopContracts.ViewModels; +using FlowerShopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowerShopListImplement.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) && string.IsNullOrEmpty(model.Password)) + { + 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) + { + foreach (var implementer in _source.Implementers) + { + if ((string.IsNullOrEmpty(model.ImplementerFIO) || implementer.ImplementerFIO == model.ImplementerFIO) && + (!model.Id.HasValue || implementer.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || implementer.Password == model.Password)) + { + 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 (model.Id == implementer.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/FlowerShopListImplement/Order.cs b/FlowerShopListImplement/Order.cs index c7dd233..5b75f9d 100644 --- a/FlowerShopListImplement/Order.cs +++ b/FlowerShopListImplement/Order.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Reflection; namespace FlowerShopListImplement.Models { @@ -17,8 +18,9 @@ namespace FlowerShopListImplement.Models public int Count { get; private set; } public double Sum { get; private set; } public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } - public OrderStatus Status { get; private set; } + public OrderStatus Status { get; private set; } public DateTime DateCreate { get; private set; } public DateTime? DateImplement { get; private set; } @@ -38,8 +40,9 @@ namespace FlowerShopListImplement.Models DateCreate = model.DateCreate, DateImplement = model.DateImplement, ClientId = model.ClientId, + ImplementerId = model.ImplementerId - }; + }; } public void Update(OrderBindingModel? model) { @@ -51,7 +54,8 @@ namespace FlowerShopListImplement.Models FlowerId = model.FlowerId; Count = model.Count; ClientId = model.ClientId; - Sum = model.Sum; + ImplementerId = model.ImplementerId; + Sum = model.Sum; Status = model.Status; DateCreate = model.DateCreate; DateImplement = model.DateImplement; @@ -61,7 +65,8 @@ namespace FlowerShopListImplement.Models Id = Id, FlowerId = FlowerId, ClientId = ClientId, - Count = Count, + ImplementerId = ImplementerId, + Count = Count, Sum = Sum, Status = Status, DateCreate = DateCreate, diff --git a/FlowerShopListImplement/OrderStorage.cs b/FlowerShopListImplement/OrderStorage.cs index 0449aa0..f6cc4d5 100644 --- a/FlowerShopListImplement/OrderStorage.cs +++ b/FlowerShopListImplement/OrderStorage.cs @@ -23,12 +23,11 @@ namespace FlowerShopListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(AccessFlowerStorage(order.GetViewModel)); + result.Add(AccessStorage(order.GetViewModel)); } return result; } - public List GetFilteredList(OrderSearchModel - model) + public List GetFilteredList(OrderSearchModel model) { var result = new List(); if (!model.Id.HasValue) @@ -40,9 +39,10 @@ namespace FlowerShopListImplement.Implements if ((!model.Id.HasValue || order.Id == model.Id) && (!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) && (!model.DateTo.HasValue || order.DateCreate <= model.DateTo) && - (!model.ClientId.HasValue || order.ClientId == model.ClientId)) + (!model.ClientId.HasValue || order.ClientId == model.ClientId)&& + (!model.Status.HasValue || order.Status == model.Status)); { - result.Add(AccessFlowerStorage(order.GetViewModel)); + result.Add(AccessStorage(order.GetViewModel)); } } return result; @@ -55,8 +55,10 @@ namespace FlowerShopListImplement.Implements } foreach (var order in _source.Orders) { - if (model.Id.HasValue && order.Id == model.Id) - { + if ((model.Id.HasValue && order.Id == model.Id) || + (model.ImplementerId.HasValue && model.Status.HasValue && + order.ImplementerId == model.ImplementerId && order.Status == model.Status)) + { return order.GetViewModel; } } @@ -106,24 +108,21 @@ namespace FlowerShopListImplement.Implements return null; } - public OrderViewModel AccessFlowerStorage(OrderViewModel model) - { - foreach (var iceCream in _source.Flowers) - { - if (iceCream.Id == model.FlowerId) - { - model.FlowerName = iceCream.FlowerName; - break; - } - } - return model; - } - public OrderViewModel AccessClientStorage(OrderViewModel model) - { - var client = _source.Clients.FirstOrDefault(x => x.Id == model.ClientId); - if (client != null) - model.ClientFIO = client.ClientFIO; - return model; - } - } + public OrderViewModel AccessStorage(OrderViewModel model) + { + if (model == null) + return null; + var flower = _source.Flowers.FirstOrDefault(x => x.Id == model.Id); + var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id); + var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId); + if (flower != null) + model.FlowerName = flower.FlowerName; + if (client != null) + model.ClientFIO = client.ClientFIO; + if (implementer != null) + model.ImplementerFIO = implementer.ImplementerFIO; + return model; + } + + } }