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

52 lines
1.2 KiB
C#

using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.ViewModels;
using BeautySaloonDataModels;
using System;
using System.Collections.Generic;
namespace BeautySaloonDatabaseImplement;
/// <summary>
/// Сущность услуги
/// </summary>
public partial class Service : IServiceModel
{
/// <summary>
/// Уникальный идентификатор
/// </summary>
public int Id { get; set; }
/// <summary>
/// Название
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// Цена
/// </summary>
public decimal Price { get; set; }
public virtual ICollection<ServiceOrder> ServiceOrders { get; } = new List<ServiceOrder>();
public static Service Create(ServiceBindingModel model)
{
return new Service()
{
Id = model.Id,
Name = model.Name,
Price = model.Price
};
}
public void Update(ServiceBindingModel model)
{
Name = model.Name;
Price = model.Price;
}
public ServiceViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Price = Price
};
}