49 lines
1.0 KiB
C#
49 lines
1.0 KiB
C#
|
using HotelContracts.BindingModels;
|
|||
|
using HotelContracts.ViewModels;
|
|||
|
using HotelDataModels.Models;
|
|||
|
|
|||
|
namespace HotelDatabaseImplement.Models;
|
|||
|
|
|||
|
public class Room : IRoomModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
public string Type { get; set; }
|
|||
|
public double Cost { get; set; }
|
|||
|
|
|||
|
public virtual Reservation Reservation { get; set; } = new();
|
|||
|
|
|||
|
public static Room? Create(RoomBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null) return null;
|
|||
|
return new Room
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Type = model.Type,
|
|||
|
Cost = model.Cost
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public static Room Create(RoomViewModel model)
|
|||
|
{
|
|||
|
return new Room
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Type = model.Type,
|
|||
|
Cost = model.Cost
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(RoomBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null) return;
|
|||
|
Type = model.Type;
|
|||
|
Cost = model.Cost;
|
|||
|
}
|
|||
|
|
|||
|
public RoomViewModel GetView => new RoomViewModel
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Type = Type,
|
|||
|
Cost = Cost
|
|||
|
};
|
|||
|
}
|