2024-04-28 12:50:59 +04:00
|
|
|
|
using PolyclinicContracts.BindingModels;
|
|
|
|
|
using PolyclinicContracts.ViewModels;
|
|
|
|
|
using PolyclinicDataModels.Enums;
|
|
|
|
|
using PolyclinicDataModels.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace PolyclinicDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class User : IUserModel
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public string FIO { get; set; } = string.Empty;
|
2024-04-28 12:50:59 +04:00
|
|
|
|
[Required]
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public string Email { get; set; } = string.Empty;
|
2024-04-28 12:50:59 +04:00
|
|
|
|
[Required]
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public string Password { get; set; } = string.Empty;
|
2024-04-28 12:50:59 +04:00
|
|
|
|
[Required]
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public UserRole Role { get; set; } = UserRole.Неизвестный;
|
|
|
|
|
public int Id { get; set; }
|
2024-04-28 12:55:26 +04:00
|
|
|
|
|
2024-04-28 12:50:59 +04:00
|
|
|
|
public static User? Create(UserBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new User
|
|
|
|
|
{
|
|
|
|
|
FIO = model.FIO,
|
|
|
|
|
Email = model.Email,
|
|
|
|
|
Password = model.Password,
|
2024-04-28 12:55:26 +04:00
|
|
|
|
Role = model.Role,
|
2024-04-28 12:50:59 +04:00
|
|
|
|
Id = model.Id
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(UserBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
FIO = model.FIO;
|
|
|
|
|
Email = model.Email;
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
FIO = FIO,
|
|
|
|
|
Email = Email,
|
|
|
|
|
Password = Password,
|
2024-04-28 12:55:26 +04:00
|
|
|
|
Role = Role,
|
2024-04-28 12:50:59 +04:00
|
|
|
|
Id = Id
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|