2023-04-09 00:34:25 +04:00
|
|
|
|
using CanteenContracts.BindingModels;
|
|
|
|
|
using CanteenContracts.BusinessLogicsContracts;
|
|
|
|
|
using CanteenContracts.View;
|
|
|
|
|
using CanteenDataModels.Models;
|
|
|
|
|
using System;
|
2023-04-07 10:55:40 +04:00
|
|
|
|
using System.Collections.Generic;
|
2023-04-09 00:34:25 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-04-07 10:55:40 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-04-09 00:34:25 +04:00
|
|
|
|
using static NHibernate.Engine.Query.CallableParser;
|
2023-04-07 10:55:40 +04:00
|
|
|
|
|
|
|
|
|
namespace CanteenDatabaseImplement.Models
|
|
|
|
|
{
|
2023-04-09 00:34:25 +04:00
|
|
|
|
public class Manager : IManagerModel
|
2023-04-07 10:55:40 +04:00
|
|
|
|
{
|
2023-04-09 00:34:25 +04:00
|
|
|
|
[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; } = new();
|
|
|
|
|
[ForeignKey("ManagerId")]
|
|
|
|
|
public virtual List<Product> Products { get; set; } = new();
|
|
|
|
|
[ForeignKey("ManagerId")]
|
|
|
|
|
public virtual List<Dish> Dishes { get; set; } = new();
|
|
|
|
|
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
|
|
|
|
|
};
|
2023-04-07 10:55:40 +04:00
|
|
|
|
}
|
|
|
|
|
}
|