70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using HotelContracts.BindingModels;
|
|
using HotelContracts.ViewModels;
|
|
using HotelDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HotelDatabaseImplement.Models
|
|
{
|
|
public class Room : IRoomModel
|
|
{
|
|
[Required]
|
|
public int WorkerId { get; set; }
|
|
[Required]
|
|
public int Number { get; set; }
|
|
[Required]
|
|
public int Floor { get; set; }
|
|
[Required]
|
|
public int NumberOfBeds { get; set; }
|
|
[Required]
|
|
public string Condition { get; set; } = string.Empty;
|
|
[Required]
|
|
public int Cost { get; set; }
|
|
|
|
public int Id { get; set; }
|
|
public static Room? Create(RoomBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
return new Room()
|
|
{
|
|
Id = model.Id,
|
|
WorkerId = model.WorkerId,
|
|
Number = model.Number,
|
|
NumberOfBeds = model.NumberOfBeds,
|
|
Condition = model.Condition,
|
|
Cost = model.Cost,
|
|
Floor = model.Floor
|
|
};
|
|
}
|
|
|
|
public void Update(RoomBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
Id = model.Id;
|
|
WorkerId = model.WorkerId;
|
|
Number = model.Number;
|
|
NumberOfBeds = model.NumberOfBeds;
|
|
Condition = model.Condition;
|
|
Cost = model.Cost;
|
|
Floor = model.Floor;
|
|
|
|
}
|
|
|
|
public RoomViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
WorkerId = WorkerId,
|
|
Number = Number,
|
|
NumberOfBeds = NumberOfBeds,
|
|
Condition = Condition,
|
|
Cost = Cost,
|
|
Floor = Floor
|
|
};
|
|
}
|
|
}
|