2023-03-28 21:24:52 +04:00
|
|
|
|
using BeautySaloonContracts.BindingModels;
|
|
|
|
|
using BeautySaloonContracts.ViewModels;
|
|
|
|
|
using BeautySaloonDataModels;
|
|
|
|
|
|
|
|
|
|
namespace BeautySaloonDatabaseImplement;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сущность сотрудники
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Employee : IEmployeeModel
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Уникальный идентификатор
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Имя
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Фамилия
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Surname { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Отчество
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string? Patronymic { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Номер телефона
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Phone { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Идентификатор позиции
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int PositionId { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual ICollection<Order> Orders { get; } = new List<Order>();
|
|
|
|
|
|
2023-03-29 20:00:53 +04:00
|
|
|
|
public virtual Position Position { get; set; }
|
2023-03-28 21:24:52 +04:00
|
|
|
|
|
|
|
|
|
public virtual ICollection<ServiceOrder> ServiceOrders { get; } = new List<ServiceOrder>();
|
|
|
|
|
|
|
|
|
|
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,
|
2023-03-29 20:00:53 +04:00
|
|
|
|
FIO = Name + ' ' + Surname + ' ' + Patronymic,
|
2023-03-28 21:24:52 +04:00
|
|
|
|
};
|
|
|
|
|
}
|