60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using HotelContracts.BindingModels;
|
|
using HotelContracts.ViewModels;
|
|
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 Client : IClientModel
|
|
{
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Surname { get; set; } = string.Empty;
|
|
[Required]
|
|
public DateTime DateOfBirth { get; set; }
|
|
[Required]
|
|
public string PhoneNumber { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
public int Id { get; set; }
|
|
public static Client Create(HotelDatabase context, ClientBindingModel model)
|
|
{
|
|
return new Client()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Surname = model.Surname,
|
|
DateOfBirth = model.DateOfBirth,
|
|
PhoneNumber = model.PhoneNumber,
|
|
Password = model.Password,
|
|
};
|
|
}
|
|
public void Update(ClientBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
Id = model.Id;
|
|
Name = model.Name;
|
|
Surname = model.Surname;
|
|
DateOfBirth = model.DateOfBirth;
|
|
PhoneNumber = model.PhoneNumber;
|
|
Password = model.Password;
|
|
}
|
|
public ClientViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
Surname = Surname,
|
|
DateOfBirth = DateOfBirth,
|
|
PhoneNumber = PhoneNumber,
|
|
Password = Password
|
|
};
|
|
}
|
|
}
|