using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; using VeterinaryClinicContracts.BindingModels; using VeterinaryClinicContracts.ViewModels; using VeterinaryClinicDataModels.Enums; using VeterinaryClinicDataModels.Models; namespace VeterinaryClinicDatabaseImplement.Models { public class User: IUserModel { public int Id { get; set; } [Required] public string FullName { get; set; } = string.Empty; [Required] public string Phone { get; set; } = string.Empty; [Required] public string Email { get; set; } = string.Empty; [Required] public string Password { get; set; } = string.Empty; [Required] public UserRole Role { get; set; } public static User? Create(UserBindingModel model) { if (model == null) { return null; } return new User() { Id = model.Id, FullName = model.FullName, Phone = model.Phone, Email = model.Email, Password = model.Password, Role = model.Role }; } public void Update(UserBindingModel model) { if (model == null) { return; } FullName = model.FullName; Phone = model.Phone; Email = model.Email; Password = model.Password; Role = model.Role; } public UserViewModel GetViewModel => new() { Id = Id, FullName = FullName, Phone = Phone, Email = Email, Password = Password, Role = Role }; } }