diff --git a/Hotel/HotelDataBaseImplement/Models/Dinner.cs b/Hotel/HotelDataBaseImplement/Models/Dinner.cs index 11e5f13..a40768c 100644 --- a/Hotel/HotelDataBaseImplement/Models/Dinner.cs +++ b/Hotel/HotelDataBaseImplement/Models/Dinner.cs @@ -1,4 +1,5 @@ -using HotelContracts.ViewModels; +using HotelContracts.BindingModels; +using HotelContracts.ViewModels; using HotelDataModels.Models; using System; using System.Collections.Generic; @@ -28,6 +29,42 @@ namespace HotelDataBaseImplement.Models [ForeignKey("DinnercId")] public virtual List ConferenceBookingDinners { get; set; } - public DinnerViewModel? GetViewModel { get; internal set; } + public static Dinner? Create(DinnerBindingModel model) + { + if (model == null) + { + return null; + } + return new Dinner() + { + Id = model.Id, + DinnerName = model.DinnerName, + DinnetPrice = model.DinnetPrice + }; + } + public static Dinner Create(DinnerViewModel model) + { + return new Dinner + { + Id = model.Id, + DinnerName = model.DinnerName, + DinnetPrice = model.DinnetPrice + }; + } + public void Update(DinnerBindingModel model) + { + if (model == null) + { + return; + } + DinnerName = model.DinnerName; + DinnetPrice = model.DinnetPrice; + } + public DinnerViewModel GetViewModel => new() + { + Id = Id, + DinnerName = DinnerName, + DinnetPrice = DinnetPrice + }; } }