2022-06-12 19:42:47 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2022-11-14 19:32:41 +00:00
|
|
|
|
using DataModel.Database.Common;
|
2022-06-12 19:42:47 +00:00
|
|
|
|
|
|
|
|
|
namespace DataModel.Database;
|
|
|
|
|
|
|
|
|
|
public sealed class TextElement
|
|
|
|
|
{
|
|
|
|
|
[Key]
|
|
|
|
|
public int Id { get; set; }
|
2022-11-06 20:07:41 +00:00
|
|
|
|
|
2023-01-22 20:39:36 +00:00
|
|
|
|
public Guid UniqueId { get; set; } = Guid.NewGuid();
|
2022-06-12 19:42:47 +00:00
|
|
|
|
|
2022-07-10 17:30:22 +00:00
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
2022-06-12 19:42:47 +00:00
|
|
|
|
public string Code { get; set; } = string.Empty;
|
|
|
|
|
|
2022-09-17 17:23:11 +00:00
|
|
|
|
public bool IsMultiLine { get; set; } = false;
|
|
|
|
|
|
2023-01-22 18:56:25 +00:00
|
|
|
|
public Section Section { get; set; } = new();
|
2022-06-12 19:42:47 +00:00
|
|
|
|
|
2022-07-10 17:30:22 +00:00
|
|
|
|
public List<Translation> Translations { get; set; } = new();
|
2022-11-14 19:32:41 +00:00
|
|
|
|
|
|
|
|
|
internal DataContext.JsonUniqueId JsonUniqueId => new(this.Code, this.UniqueId, "TXT");
|
|
|
|
|
|
|
|
|
|
internal DataContext.JsonTextElement ToJsonTextElement() => new()
|
|
|
|
|
{
|
|
|
|
|
UniqueId = this.JsonUniqueId,
|
|
|
|
|
Code = this.Code,
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
IsMultiLine = this.IsMultiLine,
|
|
|
|
|
SectionUniqueId = this.Section.JsonUniqueId,
|
|
|
|
|
Translations = this.Translations.Select(n => n.JsonUniqueId).ToList(),
|
|
|
|
|
};
|
2023-01-22 18:35:57 +00:00
|
|
|
|
|
|
|
|
|
internal static TextElement FromJsonTextElement(DataContext.JsonTextElement jsonTextElement) => new()
|
|
|
|
|
{
|
|
|
|
|
UniqueId = jsonTextElement.UniqueId.UniqueId,
|
|
|
|
|
Code = jsonTextElement.Code,
|
|
|
|
|
Name = jsonTextElement.Name,
|
|
|
|
|
IsMultiLine = jsonTextElement.IsMultiLine,
|
|
|
|
|
Section = new(),
|
|
|
|
|
Translations = new(),
|
|
|
|
|
};
|
2022-06-12 19:42:47 +00:00
|
|
|
|
}
|