From 722ab5829cad94090f2abbecd0c1a6f2ed13186e Mon Sep 17 00:00:00 2001 From: dasha Date: Mon, 10 Apr 2023 21:11:09 +0400 Subject: [PATCH] implements --- SushiBar/SushiBar/Program.cs | 2 + .../BindingModels/ImplementerBindingModel.cs | 20 +++ .../IImplementerLogic.cs | 19 +++ .../SearchModels/ImplementerSearchModel.cs | 11 ++ .../StoragesContracts/IImplementerStorage.cs | 21 ++++ .../ViewModels/ImplementerViewModel.cs | 25 ++++ .../Models/IImplementerModel.cs | 13 ++ .../Implements/ImplementerStorage.cs | 93 ++++++++++++++ .../Models/Implementer.cs | 57 +++++++++ .../SushiBarDatabaseImplement/Models/Order.cs | 1 + .../SushiBarDatabase.cs | 2 + .../DataFileSingleton.cs | 4 + .../Implements/ImplementerStorage.cs | 81 +++++++++++++ .../Models/Implementer.cs | 76 ++++++++++++ .../DataListSingleton.cs | 4 +- .../Implements/ImplementerStorage.cs | 114 ++++++++++++++++++ .../Models/Implementer.cs | 58 +++++++++ 17 files changed, 600 insertions(+), 1 deletion(-) create mode 100644 SushiBar/SushiBarContracts/BindingModels/ImplementerBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IImplementerLogic.cs create mode 100644 SushiBar/SushiBarContracts/SearchModels/ImplementerSearchModel.cs create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/IImplementerStorage.cs create mode 100644 SushiBar/SushiBarContracts/ViewModels/ImplementerViewModel.cs create mode 100644 SushiBar/SushiBarDataModels/Models/IImplementerModel.cs create mode 100644 SushiBar/SushiBarDatabaseImplement/Implements/ImplementerStorage.cs create mode 100644 SushiBar/SushiBarDatabaseImplement/Models/Implementer.cs create mode 100644 SushiBar/SushiBarFileImplement/Implements/ImplementerStorage.cs create mode 100644 SushiBar/SushiBarFileImplement/Models/Implementer.cs create mode 100644 SushiBar/SushiBarListImplement/Implements/ImplementerStorage.cs create mode 100644 SushiBar/SushiBarListImplement/Models/Implementer.cs diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs index f2c1558..d629d78 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -42,12 +42,14 @@ namespace SushiBarView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/SushiBar/SushiBarContracts/BindingModels/ImplementerBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..946ed73 --- /dev/null +++ b/SushiBar/SushiBarContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,20 @@ +using SushiBarDataModels.Models; + +namespace SushiBarContracts.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; } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IImplementerLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IImplementerLogic.cs new file mode 100644 index 0000000..0a6ec37 --- /dev/null +++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -0,0 +1,19 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; + +namespace SushiBarContracts.BusinessLogicsContracts +{ + public interface IImplementerLogic + { + List? ReadList(ImplementerSearchModel? model); + + ImplementerViewModel? ReadElement(ImplementerSearchModel model); + + bool Create(ImplementerBindingModel model); + + bool Update(ImplementerBindingModel model); + + bool Delete(ImplementerBindingModel model); + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/SearchModels/ImplementerSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/ImplementerSearchModel.cs new file mode 100644 index 0000000..378179a --- /dev/null +++ b/SushiBar/SushiBarContracts/SearchModels/ImplementerSearchModel.cs @@ -0,0 +1,11 @@ +namespace SushiBarContracts.SearchModels +{ + public class ImplementerSearchModel + { + public int? Id { get; set; } + + public string? ImplementerFIO { get; set; } + + public string? Password { get; set; } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IImplementerStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IImplementerStorage.cs new file mode 100644 index 0000000..c8e3de4 --- /dev/null +++ b/SushiBar/SushiBarContracts/StoragesContracts/IImplementerStorage.cs @@ -0,0 +1,21 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; + +namespace SushiBarContracts.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); + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/ViewModels/ImplementerViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..943aa6d --- /dev/null +++ b/SushiBar/SushiBarContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,25 @@ +using SushiBarDataModels.Models; +using System.ComponentModel; + +namespace SushiBarContracts.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; } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarDataModels/Models/IImplementerModel.cs b/SushiBar/SushiBarDataModels/Models/IImplementerModel.cs new file mode 100644 index 0000000..c1061b5 --- /dev/null +++ b/SushiBar/SushiBarDataModels/Models/IImplementerModel.cs @@ -0,0 +1,13 @@ +namespace SushiBarDataModels.Models +{ + public interface IImplementerModel : IId + { + string ImplementerFIO { get; } + + string Password { get; } + + int WorkExperience { get; } + + int Qualification { get; } + } +} diff --git a/SushiBar/SushiBarDatabaseImplement/Implements/ImplementerStorage.cs b/SushiBar/SushiBarDatabaseImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..2a62128 --- /dev/null +++ b/SushiBar/SushiBarDatabaseImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,93 @@ +using Microsoft.EntityFrameworkCore; +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarDatabaseImplement.Models; + +namespace SushiBarDatabaseImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + using var context = new SushiBarDatabase(); + var element = context.Implementers.Include(x => x.Orders).FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + context.Implementers.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + using var context = new SushiBarDatabase(); + if (model.Id.HasValue) + { + return context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel; + } + else if (!string.IsNullOrEmpty(model.ImplementerFIO)) + { + return context.Implementers.Include(x => x.Orders) + .FirstOrDefault(x => x.ImplementerFIO == model.ImplementerFIO)?.GetViewModel; + } + return null; + } + + public List GetFilteredList(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + return new(); + } + using var context = new SushiBarDatabase(); + return context.Implementers + .Include(x => x.Orders) + .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new SushiBarDatabase(); + return context.Implementers + .Include(x => x.Orders) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + var newImplementer = Implementer.Create(model); + if (newImplementer == null) + { + return null; + } + using var context = new SushiBarDatabase(); + context.Implementers.Add(newImplementer); + context.SaveChanges(); + return context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => x.Id == newImplementer.Id)?.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + using var context = new SushiBarDatabase(); + var implementer = context.Implementers.Include(x => x.Orders).FirstOrDefault(x => x.Id == model.Id); + if (implementer == null) + { + return null; + } + implementer.Update(model); + context.SaveChanges(); + return implementer.GetViewModel; + } + } +} diff --git a/SushiBar/SushiBarDatabaseImplement/Models/Implementer.cs b/SushiBar/SushiBarDatabaseImplement/Models/Implementer.cs new file mode 100644 index 0000000..b63d057 --- /dev/null +++ b/SushiBar/SushiBarDatabaseImplement/Models/Implementer.cs @@ -0,0 +1,57 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace SushiBarDatabaseImplement.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; private set; } = string.Empty; + [Required] + public int WorkExperience { get; private set; } + [Required] + public int Qualification { get; private 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 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/SushiBar/SushiBarDatabaseImplement/Models/Order.cs b/SushiBar/SushiBarDatabaseImplement/Models/Order.cs index e8bae5c..661b3c8 100644 --- a/SushiBar/SushiBarDatabaseImplement/Models/Order.cs +++ b/SushiBar/SushiBarDatabaseImplement/Models/Order.cs @@ -12,6 +12,7 @@ namespace SushiBarDatabaseImplement.Models public int SushiId { get; set; } [Required] public int ClientId { get; set; } + public int? ImplementerId { get; private set; } [Required] public int Count { get; set; } [Required] diff --git a/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs b/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs index 75c006c..c9b8aa1 100644 --- a/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs +++ b/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs @@ -23,5 +23,7 @@ namespace SushiBarDatabaseImplement public virtual DbSet Orders { set; get; } public virtual DbSet Clients { set; get; } + + public virtual DbSet Implementers { set; get; } } } diff --git a/SushiBar/SushiBarFileImplement/DataFileSingleton.cs b/SushiBar/SushiBarFileImplement/DataFileSingleton.cs index f7c957d..b4d7213 100644 --- a/SushiBar/SushiBarFileImplement/DataFileSingleton.cs +++ b/SushiBar/SushiBarFileImplement/DataFileSingleton.cs @@ -10,10 +10,12 @@ namespace SushiBarFileImplement private readonly string OrderFileName = "Order.xml"; private readonly string SushiFileName = "Sushi.xml"; private readonly string ClientFileName = "Client.xml"; + private readonly string ImplementerFileName = "Implementer.xml"; public List Ingredients { get; private set; } public List Orders { get; private set; } public List ListSushi { get; private set; } public List Clients { get; private set; } + public List Implementers { get; private set; } public static DataFileSingleton GetInstance() { if (instance == null) @@ -28,12 +30,14 @@ namespace SushiBarFileImplement "ListSushi", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); + public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement); private DataFileSingleton() { Ingredients = LoadData(IngredientFileName, "Ingredient", x => Ingredient.Create(x)!)!; ListSushi = LoadData(SushiFileName, "Sushi", x => Sushi.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/SushiBar/SushiBarFileImplement/Implements/ImplementerStorage.cs b/SushiBar/SushiBarFileImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..d5bd844 --- /dev/null +++ b/SushiBar/SushiBarFileImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,81 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarFileImplement.Models; + +namespace SushiBarFileImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + private readonly DataFileSingleton source; + public ImplementerStorage() + { + source = DataFileSingleton.GetInstance(); + } + 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; + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue) + { + return null; + } + return source.Implementers.FirstOrDefault(x => + (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO) || + (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + + 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 List GetFullList() + { + return source.Implementers.Select(x => x.GetViewModel).ToList(); + } + + 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; + } + } +} diff --git a/SushiBar/SushiBarFileImplement/Models/Implementer.cs b/SushiBar/SushiBarFileImplement/Models/Implementer.cs new file mode 100644 index 0000000..0537bcd --- /dev/null +++ b/SushiBar/SushiBarFileImplement/Models/Implementer.cs @@ -0,0 +1,76 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; +using System.Xml.Linq; + +namespace SushiBarFileImplement.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 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/SushiBar/SushiBarListImplement/DataListSingleton.cs b/SushiBar/SushiBarListImplement/DataListSingleton.cs index fb1cbc8..2afc72e 100644 --- a/SushiBar/SushiBarListImplement/DataListSingleton.cs +++ b/SushiBar/SushiBarListImplement/DataListSingleton.cs @@ -9,12 +9,14 @@ namespace SushiBarListImplement public List Orders { get; set; } public List ListSushi { get; set; } public List Clients { get; set; } + public List Implementers { get; set; } private DataListSingleton() { Ingredients = new List(); Orders = new List(); ListSushi = new List(); - Clients = new List(); + Clients = new List(); + Implementers = new List(); } public static DataListSingleton GetInstance() { diff --git a/SushiBar/SushiBarListImplement/Implements/ImplementerStorage.cs b/SushiBar/SushiBarListImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..0c1699c --- /dev/null +++ b/SushiBar/SushiBarListImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,114 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarListImplement.Models; + +namespace SushiBarListImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + private readonly DataListSingleton _source; + public ImplementerStorage() + { + _source = DataListSingleton.GetInstance(); + } + 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; + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (model.Id.HasValue) + { + foreach (var implementer in _source.Implementers) + { + if (implementer.Id == model.Id) + { + return implementer.GetViewModel; + } + } + } + else if (!string.IsNullOrEmpty(model.ImplementerFIO)) + { + foreach (var implementer in _source.Implementers) + { + if (implementer.ImplementerFIO == model.ImplementerFIO) + { + return implementer.GetViewModel; + } + } + } + return null; + } + + 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 List GetFullList() + { + var result = new List(); + foreach (var implementer in _source.Implementers) + { + result.Add(implementer.GetViewModel); + } + return result; + } + + 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; + } + } +} diff --git a/SushiBar/SushiBarListImplement/Models/Implementer.cs b/SushiBar/SushiBarListImplement/Models/Implementer.cs new file mode 100644 index 0000000..6d87636 --- /dev/null +++ b/SushiBar/SushiBarListImplement/Models/Implementer.cs @@ -0,0 +1,58 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.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 + }; + } +}