2024-04-28 20:12:32 +04:00
|
|
|
|
using BankContracts.BindingModels;
|
|
|
|
|
using BankContracts.ViewModels;
|
|
|
|
|
using BankDataModels;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2024-04-28 18:50:40 +04:00
|
|
|
|
|
|
|
|
|
namespace BankDatabaseImplement.Models
|
|
|
|
|
{
|
2024-04-28 20:12:32 +04:00
|
|
|
|
public class Client : IClientModel
|
2024-04-28 18:50:40 +04:00
|
|
|
|
{
|
2024-04-28 20:12:32 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string FirstName { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string LastName { get; private set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string? MiddleName { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string Address { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string PhoneNumber { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Password { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public List<Purchase>? Purchases { get; private set; }
|
|
|
|
|
|
|
|
|
|
public static Client Create(ClientBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Client()
|
|
|
|
|
{
|
|
|
|
|
FirstName = model.FirstName,
|
|
|
|
|
LastName = model.LastName,
|
|
|
|
|
MiddleName = model.MiddleName,
|
|
|
|
|
PhoneNumber = model.PhoneNumber,
|
|
|
|
|
Password = model.Password,
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Email = model.Email,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ClientViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
FirstName = FirstName,
|
|
|
|
|
LastName = LastName,
|
|
|
|
|
MiddleName = MiddleName,
|
|
|
|
|
PhoneNumber = PhoneNumber,
|
|
|
|
|
Password = Password,
|
|
|
|
|
Id = Id,
|
|
|
|
|
Email = Email,
|
|
|
|
|
};
|
2024-04-28 18:50:40 +04:00
|
|
|
|
}
|
|
|
|
|
}
|