SUBD_PIbd-21_Balberova_D.N./BeautySaloon/BeautySaloonDatabaseImplement/Client.cs

68 lines
1.5 KiB
C#
Raw Normal View History

2023-03-28 21:24:52 +04:00
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.ViewModels;
using BeautySaloonDataModels;
namespace BeautySaloonDatabaseImplement;
/// <summary>
/// Сущность клиенты
/// </summary>
public partial class Client : IClientModel
{
/// <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!;
public virtual ICollection<Order> Orders { get; } = new List<Order>();
public static Client Create(ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronymic,
Phone = model.Phone
};
}
public void Update(ClientBindingModel model)
{
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Phone = model.Phone;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
Patronymic = Patronymic,
Phone = Phone
};
}