2024-11-04 22:26:40 +04:00
|
|
|
|
using CandidateReviewContracts.BindingModels;
|
|
|
|
|
using CandidateReviewContracts.ViewModels;
|
|
|
|
|
using CandidateReviewDataModels.Enums;
|
|
|
|
|
using CandidateReviewDataModels.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
|
|
namespace CandidateReviewDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class User : IUserModel
|
|
|
|
|
{
|
|
|
|
|
public int? CompanyId { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string Surname { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string? LastName { get; set; }
|
2024-11-06 01:27:34 +04:00
|
|
|
|
public string? AvatarFilePath { get; set; }
|
2024-11-04 22:26:40 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string? PhoneNumber { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public bool EmailConfirmed { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public RoleEnum Role { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
public virtual Company Company { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Resume> Resumes { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("UserId")]
|
|
|
|
|
public virtual List<Assessment> Assessments { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public static User? Create(UserBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new User()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Surname = model.Surname,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
LastName = model.LastName,
|
2024-11-06 01:27:34 +04:00
|
|
|
|
AvatarFilePath = model.AvatarFilePath,
|
2024-11-04 22:26:40 +04:00
|
|
|
|
Email = model.Email,
|
|
|
|
|
Password = model.Password,
|
|
|
|
|
PhoneNumber = model.PhoneNumber,
|
|
|
|
|
EmailConfirmed = model.EmailConfirmed,
|
|
|
|
|
Role = model.Role,
|
|
|
|
|
CompanyId = model.CompanyId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static User Create(UserViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new User
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Surname = model.Surname,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
LastName = model.LastName,
|
2024-11-06 01:27:34 +04:00
|
|
|
|
AvatarFilePath = model.AvatarFilePath,
|
2024-11-04 22:26:40 +04:00
|
|
|
|
Email = model.Email,
|
|
|
|
|
Password = model.Password,
|
|
|
|
|
PhoneNumber = model.PhoneNumber,
|
|
|
|
|
EmailConfirmed = model.EmailConfirmed,
|
|
|
|
|
Role = model.Role,
|
|
|
|
|
CompanyId = model.CompanyId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(UserBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Surname = model.Surname;
|
|
|
|
|
Name = model.Name;
|
|
|
|
|
LastName = model.LastName;
|
2024-11-06 01:27:34 +04:00
|
|
|
|
AvatarFilePath = model.AvatarFilePath;
|
2024-11-04 22:26:40 +04:00
|
|
|
|
Email = model.Email;
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
PhoneNumber = model.PhoneNumber;
|
|
|
|
|
EmailConfirmed = model.EmailConfirmed;
|
|
|
|
|
Role = model.Role;
|
|
|
|
|
CompanyId = model.CompanyId;
|
|
|
|
|
}
|
2024-11-18 23:37:50 +04:00
|
|
|
|
|
2024-11-04 22:26:40 +04:00
|
|
|
|
public UserViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Name = Name,
|
|
|
|
|
Surname = Surname,
|
|
|
|
|
LastName = LastName,
|
2024-11-06 01:27:34 +04:00
|
|
|
|
AvatarFilePath = AvatarFilePath,
|
2024-11-04 22:26:40 +04:00
|
|
|
|
Email = Email,
|
|
|
|
|
Password = Password,
|
|
|
|
|
PhoneNumber = PhoneNumber,
|
|
|
|
|
EmailConfirmed = EmailConfirmed,
|
|
|
|
|
Role = Role,
|
|
|
|
|
CompanyId = CompanyId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|