Added abstraction layeer IHtmlLoader. Finished reorganizing test project folder structure.
This commit is contained in:
@@ -4,11 +4,10 @@ public class Manga
|
||||
{
|
||||
public int MangaId { get; set; }
|
||||
public required string Slug { get; set; }
|
||||
public required string Title { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
public virtual ICollection<MangaCover> Covers { get; set; } = [];
|
||||
public virtual ICollection<MangaTitle> Titles { get; set; } = [];
|
||||
public virtual ICollection<MangaDescription> Descriptions { get; set; } = [];
|
||||
public virtual ICollection<MangaSource> Sources { get; set; } = [];
|
||||
public virtual ICollection<MangaContributor> Contributors { get; set; } = [];
|
||||
public virtual ICollection<MangaGenre> Genres { get; set; } = [];
|
||||
|
||||
@@ -7,6 +7,7 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
|
||||
public DbSet<Manga> Mangas { get; set; }
|
||||
public DbSet<MangaCover> MangaCovers { get; set; }
|
||||
public DbSet<MangaTitle> MangaTitles { get; set; }
|
||||
public DbSet<MangaDescription> MangaDescriptions { get; set; }
|
||||
public DbSet<Source> Sources { get; set; }
|
||||
public DbSet<MangaSource> MangaSources { get; set; }
|
||||
public DbSet<Contributor> Contributors { get; set; }
|
||||
@@ -24,6 +25,7 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
|
||||
ConfigureManga(modelBuilder);
|
||||
ConfigureMangaCover(modelBuilder);
|
||||
ConfigureMangaTitle(modelBuilder);
|
||||
ConfigureMangaDescription(modelBuilder);
|
||||
ConfigureSource(modelBuilder);
|
||||
ConfigureMangaSource(modelBuilder);
|
||||
ConfigureContributor(modelBuilder);
|
||||
@@ -41,9 +43,9 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
|
||||
.Entity<Manga>()
|
||||
.HasKey(x => x.MangaId);
|
||||
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasIndex(x => x.Title)
|
||||
.IsUnique();
|
||||
//modelBuilder.Entity<Manga>()
|
||||
// .HasIndex(x => x.Title)
|
||||
// .IsUnique();
|
||||
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasIndex(x => x.Slug)
|
||||
@@ -81,7 +83,15 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
|
||||
.HasKey(mangaTitle => mangaTitle.MangaTitleId);
|
||||
|
||||
modelBuilder.Entity<MangaTitle>()
|
||||
.HasIndex(mangaTitle => new { mangaTitle.MangaId, mangaTitle.Name })
|
||||
.Property(mt => mt.Name)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<MangaTitle>()
|
||||
.Property(mt => mt.Language)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<MangaTitle>()
|
||||
.HasIndex(mangaTitle => new { mangaTitle.MangaId, mangaTitle.Name, mangaTitle.Language })
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder
|
||||
@@ -96,6 +106,36 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
|
||||
private static void ConfigureMangaDescription(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder
|
||||
.Entity<MangaDescription>()
|
||||
.HasKey(mangaTitle => mangaTitle.MangaTitleId);
|
||||
|
||||
modelBuilder.Entity<MangaDescription>()
|
||||
.Property(mt => mt.Name)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<MangaDescription>()
|
||||
.Property(mt => mt.Language)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<MangaDescription>()
|
||||
.HasIndex(mangaTitle => new { mangaTitle.MangaId, mangaTitle.Name, mangaTitle.Language })
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder
|
||||
.Entity<MangaDescription>()
|
||||
.HasIndex(mangaTitle => mangaTitle.Name);
|
||||
|
||||
modelBuilder
|
||||
.Entity<MangaDescription>()
|
||||
.HasOne(x => x.Manga)
|
||||
.WithMany(x => x.Descriptions)
|
||||
.HasForeignKey(x => x.MangaId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
|
||||
private static void ConfigureSource(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace MangaReader.Core.Data;
|
||||
using MangaReader.Core.Common;
|
||||
|
||||
namespace MangaReader.Core.Data;
|
||||
|
||||
public class MangaTitle
|
||||
{
|
||||
@@ -8,5 +10,6 @@ public class MangaTitle
|
||||
public required Manga Manga { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
public TitleType TitleType { get; set; }
|
||||
public required Language Language { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
namespace MangaReader.Core.Data;
|
||||
|
||||
public enum TitleType
|
||||
{
|
||||
Primary,
|
||||
OfficialTranslation,
|
||||
FanTranslation,
|
||||
Synonym,
|
||||
Abbreviation,
|
||||
Romaji,
|
||||
Japanese
|
||||
}
|
||||
//public enum TitleType
|
||||
//{
|
||||
// Primary,
|
||||
// OfficialTranslation,
|
||||
// FanTranslation,
|
||||
// Synonym,
|
||||
// Abbreviation,
|
||||
// Romaji,
|
||||
// Japanese
|
||||
//}
|
||||
Reference in New Issue
Block a user