71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using HotelContracts.BindingModels;
|
|
using HotelContracts.ViewModels;
|
|
using HotelDataModels.Enums;
|
|
using HotelDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HotelDatabaseImplement.Models
|
|
{
|
|
public class Booking : IBookingModel
|
|
{
|
|
[Required]
|
|
public int RoomId { get; set; }
|
|
[Required]
|
|
public int ClientId { get; set; }
|
|
[Required]
|
|
public DateTime ArrivalDate { get; set; }
|
|
[Required]
|
|
public DateTime DepartureDate { get; set; }
|
|
[Required]
|
|
public int NumberHoursSpent { get; set; }
|
|
[Required]
|
|
public AcceptanceStatus Status { get; set; }
|
|
[Required]
|
|
public int TotalCost { get; set; }
|
|
[Required]
|
|
public int Id { get; set; }
|
|
public static Booking Create(BookingBindingModel model)
|
|
{
|
|
return new Booking()
|
|
{
|
|
Id = model.Id,
|
|
RoomId = model.RoomId,
|
|
ClientId = model.ClientId,
|
|
ArrivalDate = model.ArrivalDate,
|
|
DepartureDate = model.DepartureDate,
|
|
NumberHoursSpent = model.NumberHoursSpent,
|
|
Status = model.Status,
|
|
TotalCost = model.TotalCost,
|
|
};
|
|
}
|
|
public void Update(BookingBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
Id = model.Id;
|
|
RoomId = model.RoomId;
|
|
ClientId = model.ClientId;
|
|
ArrivalDate = model.ArrivalDate;
|
|
DepartureDate = model.DepartureDate;
|
|
NumberHoursSpent = model.NumberHoursSpent;
|
|
Status = model.Status;
|
|
TotalCost = model.TotalCost;
|
|
}
|
|
public BookingViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
RoomId = RoomId,
|
|
ClientId = ClientId,
|
|
ArrivalDate = ArrivalDate,
|
|
DepartureDate = DepartureDate,
|
|
NumberHoursSpent = NumberHoursSpent,
|
|
Status = Status,
|
|
TotalCost = TotalCost
|
|
};
|
|
}
|
|
}
|