2023-04-09 00:34:25 +04:00
|
|
|
|
using CanteenContracts.BindingModels;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace CanteenDatabaseImplement.Models
|
|
|
|
|
{
|
2023-04-09 00:34:25 +04:00
|
|
|
|
public class Visitor : IVisitorModel
|
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("VisitorId")]
|
|
|
|
|
public virtual List<Order> Orders { get; set; } = new();
|
|
|
|
|
[ForeignKey("VisitorId")]
|
|
|
|
|
public virtual List<Lunch> Lunches { get; set; } = new();
|
|
|
|
|
[ForeignKey("VisitorId")]
|
|
|
|
|
public virtual List<Tableware> Tablewares { get; set; } = new();
|
|
|
|
|
public static Visitor? Create(VisitorBindingModel 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(VisitorBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FIO = model.FIO;
|
|
|
|
|
Login = model.Login;
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
PhoneNumber = model.PhoneNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public VisitorViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
FIO = FIO,
|
|
|
|
|
Login = Login,
|
|
|
|
|
Password = Password,
|
|
|
|
|
PhoneNumber = PhoneNumber
|
|
|
|
|
};
|
2023-04-07 10:55:40 +04:00
|
|
|
|
}
|
|
|
|
|
}
|