2024-04-29 18:23:47 +04:00
|
|
|
|
using UniversityContracts.BindingModels;
|
|
|
|
|
using UniversityContracts.ViewModels;
|
|
|
|
|
using UniversityDataModels;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace UniversityDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Client : IClientModel
|
|
|
|
|
{
|
|
|
|
|
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]
|
2024-05-26 19:47:37 +04:00
|
|
|
|
public string Login { get; private set; } = string.Empty;
|
2024-04-29 18:23:47 +04:00
|
|
|
|
[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,
|
2024-05-26 19:47:37 +04:00
|
|
|
|
Login = model.Login,
|
2024-04-29 18:23:47 +04:00
|
|
|
|
Password = model.Password,
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Email = model.Email,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ClientViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
FirstName = FirstName,
|
|
|
|
|
LastName = LastName,
|
|
|
|
|
MiddleName = MiddleName,
|
2024-05-26 19:47:37 +04:00
|
|
|
|
Login =Login,
|
2024-04-29 18:23:47 +04:00
|
|
|
|
Password = Password,
|
|
|
|
|
Id = Id,
|
|
|
|
|
Email = Email,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|