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 Section
|
|
|
|
|
{
|
|
|
|
|
[Key]
|
|
|
|
|
public int Id { get; set; }
|
2022-11-06 20:07:41 +00:00
|
|
|
|
|
|
|
|
|
public Guid UniqueId { get; set; }
|
2022-06-12 19:42:47 +00:00
|
|
|
|
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
2022-07-09 13:03:18 +00:00
|
|
|
|
public string DataKey { get; set; } = string.Empty;
|
2022-06-12 19:42:47 +00:00
|
|
|
|
|
2022-07-09 13:03:18 +00:00
|
|
|
|
public int Depth { get; set; } = 0;
|
|
|
|
|
|
|
|
|
|
public Section? Parent { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<TextElement> TextElements { get; set; } = new();
|
2022-11-14 19:32:41 +00:00
|
|
|
|
|
|
|
|
|
internal DataContext.JsonUniqueId JsonUniqueId => new(this.DataKey, this.UniqueId, "Sec");
|
|
|
|
|
|
|
|
|
|
internal DataContext.JsonSection ToJsonSection() => new()
|
|
|
|
|
{
|
|
|
|
|
UniqueId = this.JsonUniqueId,
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
DataKey = this.DataKey,
|
|
|
|
|
Depth = this.Depth,
|
|
|
|
|
ParentUniqueId = this.Parent?.JsonUniqueId ?? new DataContext.JsonUniqueId("null", Guid.Empty, "Sec"),
|
|
|
|
|
TextElements = this.TextElements.Select(n => n.JsonUniqueId).ToList()
|
|
|
|
|
};
|
2023-01-22 18:35:57 +00:00
|
|
|
|
|
|
|
|
|
internal static Section FromJsonSection(DataContext.JsonSection jsonSection) => new()
|
|
|
|
|
{
|
|
|
|
|
UniqueId = jsonSection.UniqueId.UniqueId,
|
|
|
|
|
Name = jsonSection.Name,
|
|
|
|
|
DataKey = jsonSection.DataKey,
|
|
|
|
|
Depth = jsonSection.Depth,
|
|
|
|
|
Parent = null,
|
|
|
|
|
TextElements = new(),
|
|
|
|
|
};
|
2022-06-12 19:42:47 +00:00
|
|
|
|
}
|