From 8430c05951fc6c063dcc334b64816528174233a8 Mon Sep 17 00:00:00 2001 From: ujijrujijr Date: Thu, 25 Apr 2024 01:10:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9;=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B8=D0=BB;?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B2=20Comput?= =?UTF-8?q?erShopDatabase=20=D0=BA=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BC=D0=BE=D0=B8=D1=85=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/UserBindingModel.cs | 5 +- .../SearchModels/UserSearchModel.cs | 4 +- .../ViewModels/OrderViewModel.cs | 8 +- .../ViewModels/RequestViewModel.cs | 8 +- .../ViewModels/ShipmentViewModel.cs | 6 +- .../ViewModels/UserViewModel.cs | 6 +- ComputerShopDataModels/Enums/UserRole.cs | 15 +++ ComputerShopDataModels/Models/IUserModel.cs | 4 +- .../ComputerShopDatabase.cs | 12 +- ComputerShopDatabaseImplement/Models/Order.cs | 75 +++++++++++ .../Models/Request.cs | 82 ++++++++++++ .../Models/RequestOrder.cs | 22 ++++ .../Models/Shipment.cs | 118 ++++++++++++++++++ .../Models/ShipmentOrder.cs | 25 ++++ ComputerShopDatabaseImplement/Models/User.cs | 42 ++++++- 15 files changed, 418 insertions(+), 14 deletions(-) create mode 100644 ComputerShopDataModels/Enums/UserRole.cs create mode 100644 ComputerShopDatabaseImplement/Models/Order.cs create mode 100644 ComputerShopDatabaseImplement/Models/Request.cs create mode 100644 ComputerShopDatabaseImplement/Models/RequestOrder.cs create mode 100644 ComputerShopDatabaseImplement/Models/Shipment.cs create mode 100644 ComputerShopDatabaseImplement/Models/ShipmentOrder.cs diff --git a/ComputerShopContracts/BindingModels/UserBindingModel.cs b/ComputerShopContracts/BindingModels/UserBindingModel.cs index 6031abb..c4267c9 100644 --- a/ComputerShopContracts/BindingModels/UserBindingModel.cs +++ b/ComputerShopContracts/BindingModels/UserBindingModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopDataModels.Enums; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -16,5 +17,7 @@ namespace ComputerShopContracts.BindingModels public string Password { get; set; } = string.Empty; //!!!МБ НЕ НАДО string.Empty public string Email { get; set; } = string.Empty; + //!!!МБ НЕ НАДО ПО УМОЛЧАНИЮ СТАВИТЬ "НЕИЗВЕСТНАЯ" + public UserRole Role { get; set; } = UserRole.Неизвестная; } } diff --git a/ComputerShopContracts/SearchModels/UserSearchModel.cs b/ComputerShopContracts/SearchModels/UserSearchModel.cs index cb907f2..7737112 100644 --- a/ComputerShopContracts/SearchModels/UserSearchModel.cs +++ b/ComputerShopContracts/SearchModels/UserSearchModel.cs @@ -1,4 +1,5 @@ -using System; +using ComputerShopDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,5 +15,6 @@ namespace ComputerShopContracts.SearchModels //!!!ПОИСК ПО ПАРОЛЮ НЕ СТАЛ ДОБАВЛЯТЬ, ИБО СТРАННО public string? Email { get; set; } + public UserRole? Role { get; set; } } } diff --git a/ComputerShopContracts/ViewModels/OrderViewModel.cs b/ComputerShopContracts/ViewModels/OrderViewModel.cs index 587ff10..b63f378 100644 --- a/ComputerShopContracts/ViewModels/OrderViewModel.cs +++ b/ComputerShopContracts/ViewModels/OrderViewModel.cs @@ -13,11 +13,13 @@ namespace ComputerShopContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - - //!!!ТУТ МБ НЕ НУЖЕН DisplayName - [DisplayName("Номер пользователя")] + public int UserId { get; set; } + //!!!МБ НЕ НУЖЕН string.Empty + [DisplayName("Ник пользователя")] + public string UserLogin { get; set; } = string.Empty; + //!!!ТУТ МБ НАДО DisplayName (НО ВЯРД ЛИ) //!!!УДАЛИТЬ (если нормально работает многие-ко-многим) diff --git a/ComputerShopContracts/ViewModels/RequestViewModel.cs b/ComputerShopContracts/ViewModels/RequestViewModel.cs index d420d64..f175318 100644 --- a/ComputerShopContracts/ViewModels/RequestViewModel.cs +++ b/ComputerShopContracts/ViewModels/RequestViewModel.cs @@ -14,13 +14,19 @@ namespace ComputerShopContracts.ViewModels public int Id { get; set; } //!!!ТУТ МБ НЕ НУЖЕН DisplayName - [DisplayName("Номер пользователя")] + //[DisplayName("Номер пользователя")] public int UserId { get; set; } //!!!МБ ДОБАВИТЬ НИК ПОЛЬЗОВАТЕЛЯ, СОЗДАВШЕГО ЗАЯВКУ + [DisplayName("Ник пользователя")] + public string UserLogin { get; set; } = string.Empty; + //id сборки public int AssemblyId { get; set; } + + //!!!МБ НАДО БУДЕТ ПРИВЯЗЫВАТЬ НАЗВАНИЕ СБОРКИ И Т.Д. ДЛЯ ОТЧЁТОВ + public Dictionary RequestOrders { get; set; } = new(); //!!!МБ НЕ НУЖНО DateTime.Now diff --git a/ComputerShopContracts/ViewModels/ShipmentViewModel.cs b/ComputerShopContracts/ViewModels/ShipmentViewModel.cs index 7641bf9..6bc5176 100644 --- a/ComputerShopContracts/ViewModels/ShipmentViewModel.cs +++ b/ComputerShopContracts/ViewModels/ShipmentViewModel.cs @@ -15,11 +15,11 @@ namespace ComputerShopContracts.ViewModels public int Id { get; set; } //!!!ТУТ МБ НЕ НУЖЕН DisplayName - [DisplayName("Номер пользователя")] public int UserId { get; set; } - //!!!МБ ДОБАВИТЬ НИК ПОЛЬЗОВАТЕЛЯ, СОЗДАВШЕГО ПАРТИЮ - + //!!!МБ НЕ НУЖЕН string.Empty + [DisplayName("Ник пользователя")] + public string UserLogin { get; set; } = string.Empty; public Dictionary ShipmentOrders { get; set; } = new(); diff --git a/ComputerShopContracts/ViewModels/UserViewModel.cs b/ComputerShopContracts/ViewModels/UserViewModel.cs index f36ac2d..00af73d 100644 --- a/ComputerShopContracts/ViewModels/UserViewModel.cs +++ b/ComputerShopContracts/ViewModels/UserViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopDataModels.Enums; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -22,5 +23,8 @@ namespace ComputerShopContracts.ViewModels [DisplayName("Почта")] public string Email { get; set; } = string.Empty; + + //!!!МБ ТУТ НАДО DisplayName (НО ВРЯД ЛИ) + public UserRole Role { get; set; } } } diff --git a/ComputerShopDataModels/Enums/UserRole.cs b/ComputerShopDataModels/Enums/UserRole.cs new file mode 100644 index 0000000..ae4de72 --- /dev/null +++ b/ComputerShopDataModels/Enums/UserRole.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDataModels.Enums +{ + public enum UserRole + { + Неизвестная = -1, + Исполнитель = 0, + Поручитель = 1 + } +} diff --git a/ComputerShopDataModels/Models/IUserModel.cs b/ComputerShopDataModels/Models/IUserModel.cs index 7279902..4145fba 100644 --- a/ComputerShopDataModels/Models/IUserModel.cs +++ b/ComputerShopDataModels/Models/IUserModel.cs @@ -1,4 +1,5 @@ -using System; +using ComputerShopDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,5 +12,6 @@ namespace ComputerShopDataModels.Models string Login { get; } string Password { get; } string Email { get; } + UserRole Role { get; } } } diff --git a/ComputerShopDatabaseImplement/ComputerShopDatabase.cs b/ComputerShopDatabaseImplement/ComputerShopDatabase.cs index 1cf7b34..8298b03 100644 --- a/ComputerShopDatabaseImplement/ComputerShopDatabase.cs +++ b/ComputerShopDatabaseImplement/ComputerShopDatabase.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using ComputerShopDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; namespace ComputerShopDatabaseImplement { @@ -16,5 +17,12 @@ namespace ComputerShopDatabaseImplement AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); } - } + + public virtual DbSet Orders { get; set; } + public virtual DbSet Requests { get; set; } + public virtual DbSet Shipments { get; set; } + public virtual DbSet ShipmentOrders { get; set; } + public virtual DbSet RequestOrders { get; set; } + + } } diff --git a/ComputerShopDatabaseImplement/Models/Order.cs b/ComputerShopDatabaseImplement/Models/Order.cs new file mode 100644 index 0000000..f9ba6c0 --- /dev/null +++ b/ComputerShopDatabaseImplement/Models/Order.cs @@ -0,0 +1,75 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.ViewModels; +using ComputerShopDataModels.Enums; +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDatabaseImplement.Models +{ + //!!!ДЛЯ СВЯЗИ МНОГИЕ-КО-МНОГИМ ДОБАВИТЬ ПО АНАЛОГИИ С Textile СЛОВАРИ КАСАТЕЛЬНО ПАРТИЙ И ЗАЯВОК + public class Order : IOrderModel + { + public int Id { get; set; } + + //!!!ТУТ МБ СДЕЛАТЬ КАК FOREIGN KEY + [Required] + public int UserId { get; private set; } + + [Required] + public DateTime DateCreate { get; private set; } = DateTime.Now; + + [Required] + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + + [Required] + public double Sum { get; private set; } + + //!!!мб не нужен + public virtual User User { get; set; } + + public static Order? Create(OrderBindingModel model) + { + if (model == null) + { + return null; + } + using var context = new ComputerShopDatabase(); + return new Order() + { + Id = model.Id, + UserId = model.UserId, + DateCreate = model.DateCreate, + Status = model.Status, + Sum = model.Sum, + }; + } + + public void Update(OrderBindingModel model) + { + if (model == null) + { + return; + } + using var context = new ComputerShopDatabase(); + //!!!МБ НАДО БУДЕТ ОБНОВЛЯТЬ ПОЛЬЗОВАТЕЛЯ, НО ОН ПО СУТИ НЕ ДОЛЖЕН ОБНОВЯЛТЬСЯ ПОСЛЕ СОЗДАНИЯ + Status = model.Status; + context.SaveChanges(); + } + + //!!!МБ НАДО БУДЕТ ДОБАВИТЬ В OrderViewModel ЕЩЁ ЧТО-ТО, И ТУТ ТОЖЕ + public OrderViewModel GetViewModel => new() + { + Id = Id, + UserId = UserId, + UserLogin = User.Login, + DateCreate = DateCreate, + Status = Status, + Sum = Sum + }; + } +} diff --git a/ComputerShopDatabaseImplement/Models/Request.cs b/ComputerShopDatabaseImplement/Models/Request.cs new file mode 100644 index 0000000..d55ea2b --- /dev/null +++ b/ComputerShopDatabaseImplement/Models/Request.cs @@ -0,0 +1,82 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.ViewModels; +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDatabaseImplement.Models +{ + //!!!ДОБАВИТЬ МЕТОД ПО ПРИВЯЗКЕ СБОРКИ + public class Request : IRequestModel + { + public int Id { get; set; } + [Required] + public int UserId { get; set; } + + public virtual User User { get; set; } + + public int AssemblyId { get; set; } + [Required] + public DateTime DateMake { get; set; } + [Required] + public string ClientFIO { get; set; } = string.Empty; + + private Dictionary? _requestOrders = null; + + [NotMapped] + public Dictionary RequestOrders + { + get + { + if (_requestOrders == null) + { + //!!!ТУТ ПРОПИСАТЬ ЛОГИКУ (НЕ ЗНАЮ ПОКА, КАК) + + + } + return _requestOrders; + } + } + + [ForeignKey("OrderId")] + public virtual List Orders { get; set; } = new(); + + public static Request Create(ComputerShopDatabase context, RequestBindingModel model) + { + return new Request() { + Id = model.Id, + UserId = model.UserId, + AssemblyId = model.AssemblyId, + DateMake = model.DateMake, + ClientFIO = model.ClientFIO, + Orders = model.RequestOrders.Select(x => new RequestOrder + { + Order = context.Orders.First(y => y.Id == x.Key) + }).ToList() + }; + } + //!!!МБ ТУТ ЕЩЁ ЧТО-ТО ОБНОВИТЬ + public void Update(RequestBindingModel model) + { + DateMake = model.DateMake; + ClientFIO = model.ClientFIO; + } + //!!!МБ ТУТ НЕ ВСЁ НАДО ПРИСВАИВАТЬ + public RequestViewModel GetViewModel => new() + { + Id = Id, + UserId = UserId, + UserLogin = User.Login, + AssemblyId = AssemblyId, + DateMake = DateMake, + ClientFIO = ClientFIO + }; + + //!!!ДОПИСАТЬ UpdateOrders + } +} diff --git a/ComputerShopDatabaseImplement/Models/RequestOrder.cs b/ComputerShopDatabaseImplement/Models/RequestOrder.cs new file mode 100644 index 0000000..4864fb3 --- /dev/null +++ b/ComputerShopDatabaseImplement/Models/RequestOrder.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel; + +namespace ComputerShopDatabaseImplement.Models +{ + public class RequestOrder + { + public int Id { get; set; } + [Required] + public int RequestId { get; set; } + [Required] + public int OrderId { get; set; } + //!!!МБ ТУТ КАК-ТО ПО-ДРУГОМУ + public virtual Request Request { get; set; } = new(); + public virtual Order Order { get; set; } = new(); + } +} diff --git a/ComputerShopDatabaseImplement/Models/Shipment.cs b/ComputerShopDatabaseImplement/Models/Shipment.cs new file mode 100644 index 0000000..b7113e5 --- /dev/null +++ b/ComputerShopDatabaseImplement/Models/Shipment.cs @@ -0,0 +1,118 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.ViewModels; +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDatabaseImplement.Models +{ + //!!! МОЖНО ДЕЛАТЬ ПО АНАЛОГИИ С Product(Textile) ИЛИ С Component. Делаю по аналогии с Textile + public class Shipment : IShipmentModel + { + public int Id { get; set; } + + //!!!ТУТ МБ СДЕЛАТЬ КАК FOREIGN KEY + [Required] + public int UserId { get; private set; } + + //!!!мб не нужен (для передачи логина пользователя) + public virtual User User { get; set; } + + //!!!МБ ТУТ НЕ НУЖЕН string.Empty + [Required] + public string ProviderName { get; set; } = string.Empty; + + //!!!МБ ТУТ НЕ НУЖЕН DateTime.Now + [Required] + public DateTime DateShipment { get; set; } = DateTime.Now; + + //!!!МБ ТУТ КАК-ТО ПО-ДРУГОМУ + private Dictionary? _shipmentOrders = null; + + [NotMapped] + public Dictionary? ShipmentOrders + { + get + { + if (_shipmentOrders == null) + { + //!!!ТУТ ПРОПИСАТЬ ЛОГИКУ (НЕ ЗНАЮ ПОКА, КАК) + + + } + return _shipmentOrders; + } + } + //!!!ПРОВЕРИТЬ, ЧТО ТУТ ПРАВИЛЬНО СДЕЛАНО (ЧТО НАЗВАНИЕ ПРАВИЛЬНОЕ У ВНЕШ. КЛЮЧА, ЧТО ПРАВИЛЬНЫЙ ТИП в <>) + [ForeignKey("OrderId")] + public virtual List Orders { get; set; } = new(); + + //!!!МБ ТУТ НАДО БУДЕТ ПРИСВАИВАТЬ ORDERS (но вряд ли, потому что по заданию заказы привязываются отдельно) + //!!!ПРОВЕРИТЬ, ЧТО ПРАВИЛЬНО ПРИСВАИВАЮ ЗНАЧЕНИЕ СПИСКУ ЗАКАЗОВ + public static Shipment Create(ComputerShopDatabase context, ShipmentBindingModel model) + { + return new Shipment() + { + Id = model.Id, + UserId = model.UserId, + ProviderName = model.ProviderName, + DateShipment = model.DateShipment, + Orders = model.ShipmentOrders.Select(x => new ShipmentOrder + { + Order = context.Orders.First(y => y.Id == x.Key) + }).ToList() + }; + } + //!!!МБ ТУТ КАКИЕ-ТО ДРУГИЕ ПОЛЯ НАДО БУДЕТ ОБНОВЛЯТЬ + public void Update(ShipmentBindingModel model) + { + ProviderName = model.ProviderName; + DateShipment = model.DateShipment; + } + //!!!МБ ТУТ ЕЩЁ ЧТО-ТО ПРИСВАИВАТЬ + public ShipmentViewModel GetViewModel => new() + { + Id = Id, + UserId = UserId, + UserLogin = User.Login, + ProviderName = ProviderName, + DateShipment = DateShipment, + ShipmentOrders = ShipmentOrders + }; + + //!!!МБ ЭТОТ МЕТОД БУДЕТ НЕ НУЖЕН, ПОТОМУ ЧТО ПО ЗАДАНИЮ НЕ НАПИСАНО, ЧТО МОЖНО ОБНОВЛЯТЬ + //!!!МБ НАЗВАТЬ КАК-ТО ПО-ДРУГОМУ (мб метод вынести в Implement) + //!!!МБ ПЕРЕДАВАТЬ ЧТО-ТО ДРУГОЕ + //!!!ПРОВЕРИТЬ, ЧТО ВСЁ ПРАВИЛЬНО ИЗВЛЕКАЮ + //!!!делаю как в Textile + public void UpdateOrders(ComputerShopDatabase context, ShipmentBindingModel model) + { + var shipmentOrders = context.ShipmentOrders.Where(x => x.ShipmentId == model.Id).ToList(); + //удаление тех заказов, которых нет в модели + if (shipmentOrders != null && shipmentOrders.Count > 0) + { + + //!!!ТУТ МБ НЕ x.OrderId, а x.ShipmentId, но не факт (вряд ли) + context.ShipmentOrders.RemoveRange(shipmentOrders.Where(x => !model.ShipmentOrders.ContainsKey(x.OrderId))); + context.SaveChanges(); + } + //добавление новых заказов + var currentShipment = context.Shipments.First(x => x.Id == Id); + foreach (var shipment_order in model.ShipmentOrders) + { + context.ShipmentOrders.Add(new ShipmentOrder + { + Shipment = currentShipment, + Order = context.Orders.First(x => x.Id == shipment_order.Key) + }); + context.SaveChanges(); + } + _shipmentOrders = null; + } + } +} diff --git a/ComputerShopDatabaseImplement/Models/ShipmentOrder.cs b/ComputerShopDatabaseImplement/Models/ShipmentOrder.cs new file mode 100644 index 0000000..8893d15 --- /dev/null +++ b/ComputerShopDatabaseImplement/Models/ShipmentOrder.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDatabaseImplement.Models +{ + /// + /// Класс-связь партии товаров и заказа + /// + public class ShipmentOrder + { + public int Id { get; set; } + [Required] + public int ShipmentId { get; set; } + [Required] + public int OrderId { get; set; } + + //!!!МБ ТУТ КАК-ТО ПО-ДРУГОМУ СДЕЛАТЬ + public virtual Shipment Shipment { get; set; } = new(); + public virtual Order Order { get; set; } = new(); + } +} diff --git a/ComputerShopDatabaseImplement/Models/User.cs b/ComputerShopDatabaseImplement/Models/User.cs index 48bbaa5..1c5c5e8 100644 --- a/ComputerShopDatabaseImplement/Models/User.cs +++ b/ComputerShopDatabaseImplement/Models/User.cs @@ -1,4 +1,7 @@ -using ComputerShopDataModels.Models; +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.ViewModels; +using ComputerShopDataModels.Enums; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -21,5 +24,42 @@ namespace ComputerShopDatabaseImplement.Models //!!!МБ ТУТ НУЖНА ДОП. АННОТАЦИЯ ПРОВЕРКИ ПОЧТЫ [Required] public string Email { get; set; } = string.Empty; + + //!!!МБ ТУТ НАДО ЗАДАТЬ ПО УМОЛЧАНИЮ НЕИЗВЕСТНАЯ + [Required] + public UserRole Role { get; set; } + + //!!!МБ ТУТ НАДО БУДЕТ СОЗДАТЬ 2 РАЗНЫХ МЕТОДА: СОЗДАНИЕ ИСПОЛНИТЕЛЯ и СОЗДАНИЕ ПОРУЧИТЕЛЯ (хотя мб где-то потом будем задавать роль в BindingModel) + public static User Create(UserBindingModel model) + { + return new User + { + Id = model.Id, + Login = model.Login, + Password = model.Password, + Email = model.Email + }; + } + + public void Update(UserBindingModel model) + { + if (model == null) + { + return; + } + Login = model.Login; + Password = model.Password; + Email = model.Email; + } + + //!!!МБ ТУТ НЕ НАДО РОЛЬ + public UserViewModel GetViewModel => new() + { + Id = Id, + Login = Login, + Password = Password, + Email = Email, + Role = Role + }; } }