using BeautySaloonContracts.BindingModels; using BeautySaloonContracts.ViewModels; using BeautySaloonDataModels; namespace BeautySaloonDatabaseImplement; /// /// Сущность сотрудники /// public partial class Employee : IEmployeeModel { /// /// Уникальный идентификатор /// public int Id { get; set; } /// /// Имя /// public string Name { get; set; } = null!; /// /// Фамилия /// public string Surname { get; set; } = null!; /// /// Отчество /// public string? Patronymic { get; set; } /// /// Номер телефона /// public string Phone { get; set; } = null!; /// /// Идентификатор позиции /// public int PositionId { get; set; } public virtual ICollection Orders { get; } = new List(); public virtual Position Position { get; set; } public virtual ICollection ServiceOrders { get; } = new List(); public static Employee? Create(EmployeeBindingModel? model) { if (model == null) { return null; } return new Employee() { Id = model.Id, Name = model.Name, Surname = model.Surname, Patronymic = model.Patronymic, Phone = model.Phone, PositionId = model.PositionId }; } public void Update(EmployeeBindingModel? model) { if (model == null) { return; } Name = model.Name; Surname = model.Surname; Patronymic = model.Patronymic; Phone = model.Phone; PositionId = model.PositionId; } public EmployeeViewModel GetViewModel => new() { Id = Id, Name = Name, Surname = Surname, Patronymic = Patronymic, Phone = Phone, PositionId = PositionId, PositionName = Position.Name, FIO = Name + ' ' + Surname + ' ' + Patronymic, }; }