55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using HotelContracts.BindingModels;
|
|||
|
using HotelContracts.ViewModels;
|
|||
|
using HotelDataModels.Models;
|
|||
|
|
|||
|
namespace HotelDatabaseImplement.Models;
|
|||
|
|
|||
|
public class Guest : IGuestModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
[Required]
|
|||
|
public string Name { get; set; }
|
|||
|
[Required]
|
|||
|
public string SecondName { get; set; }
|
|||
|
[Required]
|
|||
|
public string LastName { get; set; }
|
|||
|
|
|||
|
public static Guest? Create(GuestBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null) return null;
|
|||
|
return new Guest
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Name = model.Name,
|
|||
|
LastName = model.LastName,
|
|||
|
SecondName = model.SecondName
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public static Guest Create(GuestViewModel model)
|
|||
|
{
|
|||
|
return new Guest
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Name = model.Name,
|
|||
|
LastName = model.LastName,
|
|||
|
SecondName = model.SecondName
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(GuestBindingModel model)
|
|||
|
{
|
|||
|
Name = model.Name;
|
|||
|
LastName = model.LastName;
|
|||
|
SecondName = model.SecondName;
|
|||
|
}
|
|||
|
|
|||
|
public GuestViewModel GetView => new GuestViewModel
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Name = Name,
|
|||
|
LastName = LastName,
|
|||
|
SecondName = SecondName
|
|||
|
};
|
|||
|
}
|