42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using BeautySaloonContracts.BindingModels;
|
|
using BeautySaloonDataModels;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using BeautySaloonContracts.ViewModels;
|
|
|
|
namespace BeautySaloonDatabaseImplement.Models
|
|
{
|
|
public class Service : IServiceModel
|
|
{
|
|
public int Id { get; set; }
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public double Price { get; set; }
|
|
[ForeignKey("ServiceId")]
|
|
public virtual List<ServiceOrder> OrderServices { get; set; } = new();
|
|
|
|
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
|
|
};
|
|
}
|
|
}
|