2023-04-05 22:30:08 +04:00
|
|
|
|
using HotelContracts.BindingModels;
|
|
|
|
|
using HotelContracts.ViewModels;
|
2023-04-05 22:26:55 +04:00
|
|
|
|
using HotelDataModels.Models;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-04-02 15:27:07 +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 Dinner : IDinnerModel
|
|
|
|
|
{
|
2023-04-02 15:27:07 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
public int HeadwaiterId { get; set; }
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
2023-04-02 15:27:07 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string DinnerName { get; set; } = string.Empty;
|
2023-04-02 14:51:29 +04:00
|
|
|
|
|
2023-04-02 15:27:07 +04:00
|
|
|
|
[Required]
|
2023-04-07 00:16:35 +04:00
|
|
|
|
public double DinnerPrice { get; set; }
|
2023-04-02 15:27:07 +04:00
|
|
|
|
|
2023-04-02 15:45:08 +04:00
|
|
|
|
public virtual Headwaiter Headwaiters { get; set; }
|
2023-04-02 15:27:07 +04:00
|
|
|
|
|
|
|
|
|
[ForeignKey("DinnerId")]
|
2023-04-02 15:45:08 +04:00
|
|
|
|
public virtual List<RoomDinner> RoomDinners { get; set; }
|
2023-04-02 15:27:07 +04:00
|
|
|
|
|
|
|
|
|
[ForeignKey("DinnercId")]
|
2023-04-02 15:45:08 +04:00
|
|
|
|
public virtual List<ConferenceBookingDinner> ConferenceBookingDinners { get; set; }
|
2023-04-05 22:30:08 +04:00
|
|
|
|
public static Dinner? Create(DinnerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Dinner()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
DinnerName = model.DinnerName,
|
2023-04-07 00:16:35 +04:00
|
|
|
|
DinnerPrice = model.DinnerPrice
|
2023-04-05 22:30:08 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Dinner Create(DinnerViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Dinner
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
DinnerName = model.DinnerName,
|
2023-04-07 00:16:35 +04:00
|
|
|
|
DinnerPrice = model.DinnerPrice
|
2023-04-05 22:30:08 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(DinnerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DinnerName = model.DinnerName;
|
2023-04-07 00:16:35 +04:00
|
|
|
|
DinnerPrice = model.DinnerPrice;
|
2023-04-05 22:30:08 +04:00
|
|
|
|
}
|
|
|
|
|
public DinnerViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
DinnerName = DinnerName,
|
2023-04-07 00:16:35 +04:00
|
|
|
|
DinnerPrice = DinnerPrice
|
2023-04-05 22:30:08 +04:00
|
|
|
|
};
|
2023-04-02 14:51:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|