67 lines
1.6 KiB
C#
Raw Normal View History

2023-04-07 13:15:55 +04:00
using System.ComponentModel.DataAnnotations;
using HotelContracts.BindingModels;
using HotelContracts.ViewModels;
using HotelDataModels.Models;
namespace HotelDatabaseImplement.Models;
public class Maitre : IMaitreModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string SecondName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Login { get; set; }
[Required]
public string Password { get; set; }
public static Maitre Create(MaitreBindingModel model)
{
return new Maitre
{
Id = model.Id,
Name = model.Name,
SecondName = model.SecondName,
LastName = model.LastName,
Login = model.Login,
Password = model.Password
};
}
public static Maitre Create(MaitreViewModel model)
{
return new Maitre
{
Id = model.Id,
Name = model.Name,
SecondName = model.SecondName,
LastName = model.LastName,
Login = model.Login,
Password = model.Password
};
}
public void Update(MaitreBindingModel? model)
{
if (model == null) return;
Name = model.Name;
SecondName = model.SecondName;
LastName = model.LastName;
Login = model.Login;
Password = model.Password;
}
public MaitreViewModel GetViewModel => new MaitreViewModel
{
Id = Id,
Name = Name,
SecondName = SecondName,
LastName = LastName,
Login = Login,
Password = Password
};
}