2023-04-02 15:07:36 +04:00
|
|
|
|
using HotelContracts.BindingModels;
|
|
|
|
|
using HotelContracts.ViewModels;
|
|
|
|
|
using HotelDataModels.Models;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-04-02 15:07:36 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace HotelDataBaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Headwaiter : IHeadwaiterModel
|
|
|
|
|
{
|
2023-04-02 15:07:36 +04:00
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string HeadwaiterFIO { get; set; } = string.Empty;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
2023-04-02 15:07:36 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string HeadwaiterEmail { get; set; } = string.Empty;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
2023-04-02 15:07:36 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string HeadwaiterPassword { get; set; } = string.Empty;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
2023-04-02 15:07:36 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string HeadwaiterLogin { get; set; } = string.Empty;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
2023-04-02 15:07:36 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string HeadwaiterNumber { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ForeignKey("HeadwaiterId")]
|
|
|
|
|
public virtual List<Room> Rooms { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("HeadwaiterId")]
|
|
|
|
|
public virtual List<Dinner> Dinners { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("HeadwaiterId")]
|
|
|
|
|
public virtual List<ConferenceBooking> ConferenceBookings { get; set; } = new();
|
|
|
|
|
public static Headwaiter? Create(HeadwaiterBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Headwaiter()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
HeadwaiterFIO = model.HeadwaiterFIO,
|
|
|
|
|
HeadwaiterEmail = model.HeadwaiterEmail,
|
|
|
|
|
HeadwaiterPassword = model.HeadwaiterPassword,
|
|
|
|
|
HeadwaiterLogin = model.HeadwaiterLogin,
|
|
|
|
|
HeadwaiterNumber = model.HeadwaiterNumber
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Headwaiter Create(HeadwaiterViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Headwaiter
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
HeadwaiterFIO = model.HeadwaiterFIO,
|
|
|
|
|
HeadwaiterEmail = model.HeadwaiterEmail,
|
|
|
|
|
HeadwaiterPassword = model.HeadwaiterPassword,
|
|
|
|
|
HeadwaiterLogin = model.HeadwaiterLogin,
|
|
|
|
|
HeadwaiterNumber = model.HeadwaiterNumber
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(HeadwaiterBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
HeadwaiterFIO = model.HeadwaiterFIO;
|
|
|
|
|
HeadwaiterEmail = model.HeadwaiterEmail;
|
|
|
|
|
HeadwaiterPassword = model.HeadwaiterPassword;
|
|
|
|
|
HeadwaiterLogin = model.HeadwaiterLogin;
|
|
|
|
|
HeadwaiterNumber = model.HeadwaiterNumber;
|
|
|
|
|
}
|
|
|
|
|
public HeadwaiterViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
HeadwaiterFIO = HeadwaiterFIO,
|
|
|
|
|
HeadwaiterEmail = HeadwaiterEmail,
|
|
|
|
|
HeadwaiterPassword = HeadwaiterPassword,
|
|
|
|
|
HeadwaiterLogin = HeadwaiterLogin,
|
|
|
|
|
HeadwaiterNumber = HeadwaiterNumber
|
|
|
|
|
};
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|