using System.ComponentModel.DataAnnotations; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; using TravelAgencyDataModels.Models; namespace TravelAgencyDatabaseImplement.Models { public class User : IUserModel { public int Id { get; set; } [Required] public string UserFIO { get; set; } = string.Empty; [Required] public string Email { get; set; } = string.Empty; [Required] public string PhoneNumber { get; set; } = string.Empty; [Required] public string Password { get; set; } = string.Empty; public static User? Create(UserBindingModel? model) { if (model == null) { return null; } return new User() { Id = model.Id, UserFIO = model.UserFIO, Email = model.Email, PhoneNumber = model.PhoneNumber, Password = model.Password, }; } public void Update(UserBindingModel? model) { if (model == null) { return; } UserFIO = model.UserFIO; Email = model.Email; PhoneNumber = model.PhoneNumber; Password = model.Password; } public UserViewModel GetViewModel => new() { Id = Id, UserFIO = UserFIO, Email = Email, PhoneNumber = PhoneNumber, Password = Password }; } }