2023-04-07 16:35:57 +04:00
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
2023-05-18 01:15:02 +04:00
|
|
|
|
using CaseAccountingDataModels.Enum;
|
2023-04-07 16:35:57 +04:00
|
|
|
|
using CaseAccountingDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingDataBaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class User : IUserModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string Login { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[Required]
|
2023-05-18 01:15:02 +04:00
|
|
|
|
public Role Role { get; set; }
|
2023-04-07 16:35:57 +04:00
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Hearing> Hearings { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Case> Cases { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Specialization> Specializations { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Lawyer> Lawyers { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Deal> Deals { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Contract> Contracts { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public static User? Create(UserBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new User()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Login = model.Login,
|
|
|
|
|
Password = model.Password,
|
2023-05-18 01:15:02 +04:00
|
|
|
|
Role = model.Role
|
2023-04-07 16:35:57 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(UserBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Login = Login,
|
|
|
|
|
Password = Password,
|
2023-05-18 01:15:02 +04:00
|
|
|
|
Role = Role,
|
2023-04-07 16:35:57 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|