DD.WellWorkover.Cloud/AsbCloudDb/Model/TelemetryUser.cs
2023-02-20 15:06:26 +05:00

55 lines
1.5 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_telemetry_user"), Comment("Пользователи панели САУБ. Для сообщений.")]
public partial class TelemetryUser
{
[Column("id_user")]
public int IdUser { get; set; }
[Column("id_telemetry")]
public int IdTelemetry { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdTelemetry))]
[InverseProperty(nameof(Model.Telemetry.Users))]
public virtual Telemetry Telemetry { get; set; } = null!;
[Column("name")]
[StringLength(255)]
public string? Name { get; set; }
[Column("surname")]
[StringLength(255)]
public string Surname { get; set; } = null!;
[Column("patronymic")]
[StringLength(255)]
public string? Patronymic { get; set; }
[Column("level")]
public int? Level { get; set; }
public string MakeDisplayName()
{
if (!string.IsNullOrEmpty(Surname))
{
var s = Surname;
if (!string.IsNullOrEmpty(Name))
{
s += $"{Name[0]}.";
if (!string.IsNullOrEmpty(Patronymic))
s += $" {Patronymic[0]}.";
}
return s;
}
else
return $"User #{IdTelemetry}";
}
}
}