From bc32dba8f933f08167c6502585a00504a34db8b2 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sun, 28 Apr 2024 12:50:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D0=B1=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/User.cs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Polyclinic/PolyclinicDatabaseImplement/Models/User.cs diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs new file mode 100644 index 0000000..4b1aca3 --- /dev/null +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs @@ -0,0 +1,55 @@ +using PolyclinicContracts.BindingModels; +using PolyclinicContracts.ViewModels; +using PolyclinicDataModels.Enums; +using PolyclinicDataModels.Models; +using System.ComponentModel.DataAnnotations; + +namespace PolyclinicDatabaseImplement.Models +{ + public class User : IUserModel + { + [Required] + public string FIO { get; private set; } = string.Empty; + [Required] + public string Email { get; private set; } = string.Empty; + [Required] + public string Password { get; private set; } = string.Empty; + [Required] + public UserRole Role { get; private set; } = UserRole.Неизвестный; + public int Id { get; private set; } + public static User? Create(UserBindingModel? model) + { + if (model == null) + { + return null; + } + return new User + { + FIO = model.FIO, + Email = model.Email, + Password = model.Password, + Id = model.Id + }; + } + + public void Update(UserBindingModel? model) + { + if (model == null) + { + return; + } + FIO = model.FIO; + Email = model.Email; + Password = model.Password; + FIO = model.FIO; + } + + public UserViewModel GetViewModel => new() + { + FIO = FIO, + Email = Email, + Password = Password, + Id = Id + }; + } +}