34 lines
1020 B
C#
34 lines
1020 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using DataModel.Database.Common;
|
|
|
|
namespace DataModel.Database;
|
|
|
|
public sealed class Section
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
public Guid UniqueId { get; set; }
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public string DataKey { get; set; } = string.Empty;
|
|
|
|
public int Depth { get; set; } = 0;
|
|
|
|
public Section? Parent { get; set; }
|
|
|
|
public List<TextElement> TextElements { get; set; } = new();
|
|
|
|
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()
|
|
};
|
|
} |