50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using SushiBarContracts.BindingModels;
|
|
using SushiBarContracts.SearchModels;
|
|
using SushiBarContracts.ViewModels;
|
|
using SushiBarDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SushiBarDatabaseImplement.Models
|
|
{
|
|
public class Buyer : IBuyerModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string BuyerName { get; set; } = string.Empty;
|
|
|
|
public DateTime? BuyerBirthDate { get; set; }
|
|
|
|
public static Buyer? Create(BuyerBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
|
|
return new Buyer()
|
|
{
|
|
Id = model.Id,
|
|
BuyerName = model.BuyerName,
|
|
BuyerBirthDate = model.BuyerBirthDate
|
|
};
|
|
}
|
|
|
|
public void Update(BuyerBindingModel model)
|
|
{
|
|
if(model == null) return;
|
|
BuyerName = model.BuyerName;
|
|
BuyerBirthDate = model.BuyerBirthDate;
|
|
}
|
|
|
|
public BuyerViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
BuyerName = BuyerName,
|
|
BuyerBirthDate = BuyerBirthDate
|
|
};
|
|
}
|
|
}
|