65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using CanteenContracts.BindingModels;
|
|
using CanteenContracts.View;
|
|
using CanteenDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CanteenDatabaseImplement.Models
|
|
{
|
|
public class Cook : ICookModel
|
|
{
|
|
public int Id { get; private set; }
|
|
[Required]
|
|
public int ManagerId { get; private set; }
|
|
[Required]
|
|
public string FIO { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Position { get; private set; } = string.Empty;
|
|
[ForeignKey("CookId")]
|
|
public virtual List<ProductCook> Products { get; set; } = new();
|
|
[ForeignKey("CookId")]
|
|
public virtual List<OrderCook> Orders { get; set; } = new();
|
|
public virtual Manager Manager { get; set; }
|
|
|
|
public static Cook Create(CookBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new Cook
|
|
{
|
|
Id = model.Id,
|
|
ManagerId = model.ManagerId,
|
|
FIO = model.FIO,
|
|
Position = model.Position
|
|
};
|
|
}
|
|
|
|
public void Update(CookBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
FIO = model.FIO;
|
|
Position = model.Position;
|
|
}
|
|
|
|
public CookViewModel GetViewModel => new CookViewModel
|
|
{
|
|
Id = Id,
|
|
ManagerId = ManagerId,
|
|
FIO = FIO,
|
|
Position = Position
|
|
};
|
|
}
|
|
}
|