I18NCommander/I18N Commander/DataModel/Database/Section.cs
Thorsten Sommer 0587af18f2
Added Git Export Feature
- Added import algorithm
- Added FromJsonX() methods to data models
- Added possibility to work with temp. database file
- Added export processor to handle export process & triggers
- Added something changed event e.g. as export trigger
- Added possibility to import a JSON export
- Updated Git icon
2023-01-22 19:35:57 +01:00

44 lines
1.3 KiB
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()
};
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(),
};
}