2021-04-02 17:28:07 +05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudDb.Model
|
|
|
|
|
{
|
|
|
|
|
[Table("t_user"), Comment("Пользователи облака")]
|
2021-04-23 10:21:25 +05:00
|
|
|
|
public partial class User : IId
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
|
|
|
|
[Key]
|
|
|
|
|
[Column("id")]
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[Column("id_customer")]
|
|
|
|
|
public int? IdCustomer { 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; }
|
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
[Column("name"), Comment("имя")]
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[StringLength(255)]
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
[Column("surname"), Comment("фамилия")]
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[StringLength(255)]
|
|
|
|
|
public string Surname { get; set; }
|
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
[Column("patronymic"), Comment("отчество")]
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[StringLength(255)]
|
|
|
|
|
public string Patronymic { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey(nameof(IdCustomer))]
|
|
|
|
|
[InverseProperty(nameof(Model.Customer.Users))]
|
|
|
|
|
public virtual Customer Customer { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey(nameof(IdRole))]
|
|
|
|
|
[InverseProperty(nameof(Model.UserRole.Users))]
|
|
|
|
|
public virtual UserRole Role { get; set; }
|
2021-04-23 10:21:25 +05:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
}
|