DD.WellWorkover.Cloud/AsbCloudApp/Data/UserDto.cs

89 lines
2.1 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data
{
/// <summary>
/// DTO пользователя платформы
/// </summary>
public class UserDto : IId
{
/// <inheritdoc/>
public int Id { get; set; }
/// <summary>
/// логин
/// </summary>
[Required]
[StringLength(255, MinimumLength = 2)]
public string Login { get; set; } = null!;
/// <summary>
/// Имя
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Фамилия
/// </summary>
public string? Surname { get; set; }
/// <summary>
/// Отчество
/// </summary>
public string? Patronymic { get; set; }
/// <summary>
/// Email
/// </summary>
[Required]
[StringLength(255, MinimumLength = 6)]
public string Email { get; set; } = null!;
/// <summary>
/// Phone
/// </summary>
public string? Phone { get; set; }
/// <summary>
/// Должность
/// </summary>
public string? Position { get; set; }
/// <summary>
/// Id компании
/// </summary>
[Required]
public int IdCompany { get; set; }
/// <summary>
/// Id состояния пользователя
/// </summary>
public short? IdState { get; set; }
/// <summary>
/// DTO компании
/// </summary>
public CompanyDto? Company { get; set; }
/// <summary>
/// Получение отображаемого имени
/// </summary>
/// <returns></returns>
public string MakeDisplayName()
{
if (string.IsNullOrEmpty(Surname))
return Login;
var s = Surname;
if (!string.IsNullOrEmpty(Name))
{
s += $"{Name[0]}.";
if (!string.IsNullOrEmpty(Patronymic))
s += $" {Patronymic[0]}.";
}
return s;
}
}
}