diff --git a/Hotel/HotelDataBaseImplement/Models/Headwaiter.cs b/Hotel/HotelDataBaseImplement/Models/Headwaiter.cs index 0e6f1a0..202843c 100644 --- a/Hotel/HotelDataBaseImplement/Models/Headwaiter.cs +++ b/Hotel/HotelDataBaseImplement/Models/Headwaiter.cs @@ -1,6 +1,10 @@ -using HotelDataModels.Models; +using HotelContracts.BindingModels; +using HotelContracts.ViewModels; +using HotelDataModels.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; @@ -9,16 +13,82 @@ namespace HotelDataBaseImplement.Models { public class Headwaiter : IHeadwaiterModel { - public string HeadwaiterFIO => throw new NotImplementedException(); + public int Id { get; private set; } + + [Required] + public string HeadwaiterFIO { get; set; } = string.Empty; - public string HeadwaiterPassword => throw new NotImplementedException(); + [Required] + public string HeadwaiterEmail { get; set; } = string.Empty; - public string HeadwaiterLogin => throw new NotImplementedException(); + [Required] + public string HeadwaiterPassword { get; set; } = string.Empty; - public string HeadwaiterEmail => throw new NotImplementedException(); + [Required] + public string HeadwaiterLogin { get; set; } = string.Empty; - public string HeadwaiterNumber => throw new NotImplementedException(); + [Required] + public string HeadwaiterNumber { get; set; } = string.Empty; + + + [ForeignKey("HeadwaiterId")] + public virtual List Rooms { get; set; } = new(); + + [ForeignKey("HeadwaiterId")] + public virtual List Dinners { get; set; } = new(); + + [ForeignKey("HeadwaiterId")] + public virtual List 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; + } + Id = model.Id; + 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 + }; - public int Id => throw new NotImplementedException(); } }