From 3a4d415c562af438b25e91d09a0996d1ae40a2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Wed, 5 Apr 2023 22:30:08 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5/=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B2=20Dinner=20=D0=B8=D0=B7=20HotelDataBaseIm?= =?UTF-8?q?plement.Models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hotel/HotelDataBaseImplement/Models/Dinner.cs | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) 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 + }; } }