using CarCenterContracts.BindingModels; using CarCenterContracts.ViewModels; using CarCenterDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace CarCenterDatabaseImplement.Models { public class Boss : IBossModel { public int Id { get; set; } public string Login { get; set; } = string.Empty; public string Password { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public string Surname { get; set; } = string.Empty; public string? Patronymic {get; set; } public static Boss? Create(BossBindingModel model) { if (model == null) { return null; } return new Boss() { Id = model.Id, Login = model.Login, Password = model.Password, Surname = model.Surname, Name = model.Name, Patronymic = model.Patronymic, }; } public static Boss? Create(BossViewModel model) { return new Boss() { Id = model.Id, Login = model.Login, Password = model.Password, Surname = model.Surname, Name = model.Name, Patronymic = model.Patronymic, }; } public void Update(BossBindingModel? model) { if (model == null) { return; } Password = model.Password; Login = model.Login; Surname = model.Surname; Name = model.Name; Patronymic = model.Patronymic; } public BossViewModel GetViewModel => new() { Id = Id, Login = Login, Password = Password, Surname = Surname, Name = Name, Patronymic = Patronymic, }; } }