DD.WellWorkover.Cloud/AsbCloudDb/Model/User.cs
2021-07-27 16:55:32 +05:00

77 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_user"), Comment("Пользователи облака")]
public partial class User : IId
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_company")]
public int? IdCompany { get; set; }
[Column("id_role")]
public int? IdRole { get; set; }
[Column("login")]
[StringLength(255)]
public string Login { get; set; }
[Column("password_hash"), Comment("соленый хэш пароля.\nпервые 5 символов - соль")]
[StringLength(255)]
public string PasswordHash { get; set; }
[Column("state"), Comment("состояние:\n100 - удален")]
public short? State { get; set; }
[Column("level")]
public int? Level { get; set; }
[Column("name"), Comment("имя")]
[StringLength(255)]
public string Name { get; set; }
[Column("surname"), Comment("фамилия")]
[StringLength(255)]
public string Surname { get; set; }
[Column("patronymic"), Comment("отчество")]
[StringLength(255)]
public string Patronymic { get; set; }
[ForeignKey(nameof(IdCompany))]
[InverseProperty(nameof(Model.Company.Users))]
public virtual Company Company { get; set; }
[ForeignKey(nameof(IdRole))]
[InverseProperty(nameof(Model.UserRole.Users))]
public virtual UserRole Role { get; set; }
public virtual ICollection<File> Files { get; set; }
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;
}
}
}