50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using SushiBarContracts.BindingModels;
|
|
using SushiBarContracts.ViewModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace SushiBarDatabaseImplement.Models
|
|
{
|
|
public class Customer
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string Fio { get; set; } = string.Empty;
|
|
|
|
public DateTime? BirthdayDate { get; set; }
|
|
|
|
[Required]
|
|
public double SumOfAllOrders { get; set; }
|
|
|
|
[ForeignKey("CustomerId")]
|
|
public virtual List<Cheque> Cheques { get; set; } = new();
|
|
|
|
public static Customer? Create(CustomerBindingModel Model)
|
|
{
|
|
return new Customer()
|
|
{
|
|
Fio = Model.Fio,
|
|
BirthdayDate = Model.BirthdayDate,
|
|
SumOfAllOrders = Model.SumOfAllOrders,
|
|
};
|
|
}
|
|
|
|
public void Update(CustomerBindingModel Model)
|
|
{
|
|
Fio = Model.Fio;
|
|
BirthdayDate = Model.BirthdayDate;
|
|
SumOfAllOrders = Model.SumOfAllOrders;
|
|
}
|
|
|
|
public CustomerViewModel ViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Fio = Fio,
|
|
BirthdayDate = BirthdayDate,
|
|
SumOfAllOrders = SumOfAllOrders,
|
|
};
|
|
}
|
|
}
|