74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
using CanteenContracts.BindingModels;
|
|
using CanteenContracts.BusinessLogicsContracts;
|
|
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;
|
|
using static NHibernate.Engine.Query.CallableParser;
|
|
|
|
namespace CanteenDatabaseImplement.Models
|
|
{
|
|
public class Manager : IManagerModel
|
|
{
|
|
[Required]
|
|
public string FIO { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Login { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Password { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string PhoneNumber { get; private set; } = string.Empty;
|
|
|
|
public int Id { get; private set; }
|
|
[ForeignKey("ManagerId")]
|
|
public virtual List<Cook> Cooks { get; set; }
|
|
[ForeignKey("ManagerId")]
|
|
public virtual List<Product> Products { get; set; }
|
|
[ForeignKey("ManagerId")]
|
|
public virtual List<Dish> Dishes { get; set; }
|
|
public static Manager? Create(ManagerBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new()
|
|
{
|
|
Id = model.Id,
|
|
FIO = model.FIO,
|
|
Login = model.Login,
|
|
Password = model.Password,
|
|
PhoneNumber = model.PhoneNumber
|
|
};
|
|
}
|
|
|
|
public void Update(ManagerBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
FIO = model.FIO;
|
|
Login = model.Login;
|
|
Password = model.Password;
|
|
PhoneNumber = model.PhoneNumber;
|
|
}
|
|
|
|
public ManagerViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
FIO = FIO,
|
|
Login = Login,
|
|
Password = Password,
|
|
PhoneNumber = PhoneNumber
|
|
};
|
|
}
|
|
}
|