using System.ComponentModel.DataAnnotations; using HotelContracts.BindingModels; using HotelContracts.ViewModels; using HotelDataModels.Models; namespace HotelDatabaseImplement.Models; public class Maitre : IMaitreModel { public int Id { get; set; } [Required] public string Name { get; set; } [Required] public string SecondName { get; set; } [Required] public string LastName { get; set; } [Required] public string Login { get; set; } [Required] public string Password { get; set; } public static Maitre Create(MaitreBindingModel model) { return new Maitre { Id = model.Id, Name = model.Name, SecondName = model.SecondName, LastName = model.LastName, Login = model.Login, Password = model.Password }; } public static Maitre Create(MaitreViewModel model) { return new Maitre { Id = model.Id, Name = model.Name, SecondName = model.SecondName, LastName = model.LastName, Login = model.Login, Password = model.Password }; } public void Update(MaitreBindingModel? model) { if (model == null) return; Name = model.Name; SecondName = model.SecondName; LastName = model.LastName; Login = model.Login; Password = model.Password; } public MaitreViewModel GetViewModel => new MaitreViewModel { Id = Id, Name = Name, SecondName = SecondName, LastName = LastName, Login = Login, Password = Password }; }