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

90 lines
2.2 KiB
C#
Raw Normal View History

2023-02-20 12:18:45 +05:00
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data
{
2023-02-20 12:18:45 +05:00
#nullable enable
2022-06-02 12:35:51 +05:00
/// <summary>
/// DTO пользователя платформы
/// </summary>
2022-04-11 18:00:34 +05:00
public class UserDto : IId
{
2022-06-02 12:35:51 +05:00
/// <inheritdoc/>
public int Id { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// логин
/// </summary>
2023-02-20 12:18:45 +05:00
[Required]
[StringLength(255, MinimumLength = 2)]
public string Login { get; set; } = null!;
2022-06-02 12:35:51 +05:00
/// <summary>
/// Имя
/// </summary>
2023-02-20 12:18:45 +05:00
public string? Name { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// Фамилия
/// </summary>
2023-02-20 12:18:45 +05:00
public string? Surname { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// Отчество
/// </summary>
2023-02-20 12:18:45 +05:00
public string? Patronymic { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// Email
/// </summary>
2023-02-20 12:18:45 +05:00
[Required]
[StringLength(255, MinimumLength = 6)]
public string Email { get; set; } = null!;
2022-06-02 12:35:51 +05:00
/// <summary>
/// Phone
/// </summary>
2023-02-20 12:18:45 +05:00
public string? Phone { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// Должность
/// </summary>
2023-02-20 12:18:45 +05:00
public string? Position { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// Id компании
/// </summary>
2023-02-20 12:18:45 +05:00
[Required]
public int IdCompany { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// Id состояния пользователя
/// </summary>
public short? IdState { get; set; }
2022-06-02 12:35:51 +05:00
/// <summary>
/// DTO компании
/// </summary>
2023-02-20 12:18:45 +05:00
public CompanyDto? Company { get; set; }
2022-10-27 15:49:22 +05:00
/// <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;
}
}
}