Реализована модель сущности пользователь для бд
This commit is contained in:
parent
1cf08b61fa
commit
bc32dba8f9
55
Polyclinic/PolyclinicDatabaseImplement/Models/User.cs
Normal file
55
Polyclinic/PolyclinicDatabaseImplement/Models/User.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using PolyclinicContracts.BindingModels;
|
||||
using PolyclinicContracts.ViewModels;
|
||||
using PolyclinicDataModels.Enums;
|
||||
using PolyclinicDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace PolyclinicDatabaseImplement.Models
|
||||
{
|
||||
public class User : IUserModel
|
||||
{
|
||||
[Required]
|
||||
public string FIO { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public UserRole Role { get; private set; } = UserRole.Неизвестный;
|
||||
public int Id { get; private set; }
|
||||
public static User? Create(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new User
|
||||
{
|
||||
FIO = model.FIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
Id = model.Id
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FIO = model.FIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
FIO = model.FIO;
|
||||
}
|
||||
|
||||
public UserViewModel GetViewModel => new()
|
||||
{
|
||||
FIO = FIO,
|
||||
Email = Email,
|
||||
Password = Password,
|
||||
Id = Id
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user