using System; using System.Collections.Generic; using TaskTrackerContracts.BindingModels; using TaskTrackerContracts.ViewModels; namespace TaskTrackerDatabaseImplement; /// /// Сущность "Сотрудник" /// public partial class Employee { /// /// Идентификатор сущности "Сотрудник" /// public int Id { get; set; } /// /// ФИО сотрудника /// public string Name { get; set; } = null!; /// /// Должность сотрудника /// public string JobTitle { get; set; } = null!; /// /// E-mail сотрудника /// public string Email { get; set; } = null!; /// /// Ссылка на идентификатор компании в которой работает сотрудник /// public int? CompanyId { get; set; } public virtual Company Company { get; set; } = null!; public virtual ICollection TaskAssigments { get; set; } = new List(); public static Employee? Create(EmployeeBindingModel model) { if (model == null) { return null; } return new Employee() { Name = model.Name, Email = model.Email, JobTitle = model.JobTitle, CompanyId = model.CompanyId, Id = model.Id }; } public static Employee Create(EmployeeViewModel model) { return new Employee() { Name = model.Name, Email = model.Email, JobTitle = model.JobTitle, CompanyId = model.CompanyId, Id = model.Id }; } public void Update(EmployeeBindingModel model) { if (model == null) { return; } Name = model.Name; Email = model.Email; JobTitle = model.JobTitle; CompanyId = model.CompanyId; } public EmployeeViewModel GetViewModel => new() { Name = Name, Email = Email, JobTitle = JobTitle, CompanyId = CompanyId, Id = Id }; }