DD.WellWorkover.Cloud/AsbCloudDb/Model/TelemetryUser.cs
2021-04-23 10:21:25 +05:00

59 lines
1.6 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
#nullable disable
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; }
[Column("name")]
[StringLength(255)]
public string Name { get; set; }
[Column("surname")]
[StringLength(255)]
public string Surname { get; set; }
[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}";
}
}
}