diff --git a/I18N Commander/DataModel/Database/Common/DataContext.cs b/I18N Commander/DataModel/Database/Common/DataContext.cs index 43d1c5d..3d9971d 100644 --- a/I18N Commander/DataModel/Database/Common/DataContext.cs +++ b/I18N Commander/DataModel/Database/Common/DataContext.cs @@ -6,6 +6,12 @@ public sealed class DataContext : DbContext { public DbSet? Settings { get; set; } + public DbSet
? Sections { get; set; } + + public DbSet? TextElements { get; set; } + + public DbSet? Translations { get; set; } + public DataContext(DbContextOptions contextOptions) : base(contextOptions) { } @@ -14,7 +20,7 @@ public sealed class DataContext : DbContext { base.OnModelCreating(modelBuilder); - #region Ideas + #region Settings modelBuilder.Entity().HasIndex(n => n.Id); modelBuilder.Entity().HasIndex(n => n.Name).IsUnique(); @@ -24,5 +30,27 @@ public sealed class DataContext : DbContext modelBuilder.Entity().HasIndex(n => n.TextValue); #endregion + + #region Sections + + modelBuilder.Entity
().HasIndex(n => n.Id); + modelBuilder.Entity
().HasIndex(n => n.Name); + + #endregion + + #region TextElements + + modelBuilder.Entity().HasIndex(n => n.Id); + modelBuilder.Entity().HasIndex(n => n.Code); + + #endregion + + #region Translations + + modelBuilder.Entity().HasIndex(n => n.Id); + modelBuilder.Entity().HasIndex(n => n.Culture); + modelBuilder.Entity().HasIndex(n => n.Text); + + #endregion } } \ No newline at end of file diff --git a/I18N Commander/DataModel/Database/Section.cs b/I18N Commander/DataModel/Database/Section.cs new file mode 100644 index 0000000..b7f4c60 --- /dev/null +++ b/I18N Commander/DataModel/Database/Section.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace DataModel.Database; + +public sealed class Section +{ + [Key] + public int Id { get; set; } + + public string Name { get; set; } = string.Empty; + + public Section Parent { get; set; } + + public List TextElements { get; set; } +} \ No newline at end of file diff --git a/I18N Commander/DataModel/Database/Setting.cs b/I18N Commander/DataModel/Database/Setting.cs index 3f847d6..cf0dc62 100644 --- a/I18N Commander/DataModel/Database/Setting.cs +++ b/I18N Commander/DataModel/Database/Setting.cs @@ -2,7 +2,7 @@ namespace DataModel.Database; -public class Setting +public sealed class Setting { [Key] public int Id { get; set; } diff --git a/I18N Commander/DataModel/Database/TextElement.cs b/I18N Commander/DataModel/Database/TextElement.cs new file mode 100644 index 0000000..2135ffe --- /dev/null +++ b/I18N Commander/DataModel/Database/TextElement.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace DataModel.Database; + +public sealed class TextElement +{ + [Key] + public int Id { get; set; } + + public string Code { get; set; } = string.Empty; + + public Section Section { get; set; } + + public List Translations { get; set; } +} \ No newline at end of file diff --git a/I18N Commander/DataModel/Database/Translation.cs b/I18N Commander/DataModel/Database/Translation.cs new file mode 100644 index 0000000..2b5b874 --- /dev/null +++ b/I18N Commander/DataModel/Database/Translation.cs @@ -0,0 +1,12 @@ +namespace DataModel.Database; + +public sealed class Translation +{ + public int Id { get; set; } + + public TextElement TextElement { get; set; } + + public string Culture { get; set; } = "en-US"; + + public string Text { get; set; } = string.Empty; +} \ No newline at end of file