Добавление/изменение в Dinner из HotelDataBaseImplement.Models

This commit is contained in:
Кашин Максим 2023-04-05 22:30:08 +04:00
parent ae008bcd89
commit 3a4d415c56

View File

@ -1,4 +1,5 @@
using HotelContracts.ViewModels; using HotelContracts.BindingModels;
using HotelContracts.ViewModels;
using HotelDataModels.Models; using HotelDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -28,6 +29,42 @@ namespace HotelDataBaseImplement.Models
[ForeignKey("DinnercId")] [ForeignKey("DinnercId")]
public virtual List<ConferenceBookingDinner> ConferenceBookingDinners { get; set; } public virtual List<ConferenceBookingDinner> 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
};
} }
} }