Added abstraction layeer IHtmlLoader. Finished reorganizing test project folder structure.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user