ISEbd-21_Khaliullov_R.A._Co.../Canteen/CanteenDatabaseImplement/Models/Cook.cs
Руслан Халиуллов 0cf8214b3e 2 этап
2024-04-30 18:48:42 +04:00

65 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CanteenDataModels.Models;
using CanteenContracts.BindingModels;
using CanteenContracts.ViewModels;
using System.Net;
namespace CanteenDatabaseImplement.Models
{
public class Cook : ICookModel
{
public int Id { get; private set; }
[Required]
public string CookFIO { get; private set; } = string.Empty;
[Required]
public string Email { get; private set; } = string.Empty;
[Required]
public string Password { get; private set; } = string.Empty;
[ForeignKey("CookId")]
public virtual List<Order> Orders { get; set; } = new();
public static Cook? Create(CookBindingModel model)
{
if (model == null)
{
return null;
}
return new Cook()
{
Id = model.Id,
CookFIO = model.CookFIO,
Email = model.Email,
Password = model.Password,
};
}
public void Update(CookBindingModel model)
{
if (model == null)
{
return;
}
CookFIO = model.CookFIO;
Email = model.Email;
Password = model.Password;
}
public CookViewModel GetViewModel => new()
{
Id = Id,
CookFIO = CookFIO,
Email = Email,
Password = Password,
};
}
}