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]
|
|
|
|
|
public double DinnetPrice { get; set; }
|
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
|
|
};
|
2023-04-02 14:51:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|