Added contributor classes for manga. Implemented MangaDex search.

This commit is contained in:
2025-05-24 15:56:44 -04:00
parent f760cff21f
commit 1a752bb57e
20 changed files with 706 additions and 24 deletions

View File

@@ -9,6 +9,8 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
public DbSet<MangaTitle> MangaTitles { get; set; }
public DbSet<Source> Sources { get; set; }
public DbSet<MangaSource> MangaSources { get; set; }
public DbSet<Contributor> Contributors { get; set; }
public DbSet<MangaContributor> MangaContributors { get; set; }
public DbSet<Genre> Genres { get; set; }
public DbSet<MangaGenre> MangaGenres { get; set; }
public DbSet<MangaChapter> MangaChapters { get; set; }
@@ -24,6 +26,8 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
ConfigureMangaTitle(modelBuilder);
ConfigureSource(modelBuilder);
ConfigureMangaSource(modelBuilder);
ConfigureContributor(modelBuilder);
ConfigureMangaContributor(modelBuilder);
ConfigureGenre(modelBuilder);
ConfigureMangaGenre(modelBuilder);
ConfigureMangaChapter(modelBuilder);
@@ -37,6 +41,10 @@ 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.Slug)
.IsUnique();
@@ -118,6 +126,32 @@ public class MangaContext(DbContextOptions options) : DbContext(options)
.OnDelete(DeleteBehavior.Cascade);
}
private static void ConfigureContributor(ModelBuilder modelBuilder)
{
modelBuilder
.Entity<Contributor>()
.HasKey(x => x.ContributorId);
modelBuilder
.Entity<Contributor>()
.HasIndex(x => x.Name)
.IsUnique(true);
}
private static void ConfigureMangaContributor(ModelBuilder modelBuilder)
{
modelBuilder
.Entity<MangaContributor>()
.HasKey(mc => new { mc.MangaId, mc.ContributorId, mc.Role });
modelBuilder
.Entity<MangaContributor>()
.HasOne(x => x.Manga)
.WithMany(x => x.Contributors)
.HasForeignKey(x => x.MangaId)
.OnDelete(DeleteBehavior.Cascade);
}
private static void ConfigureGenre(ModelBuilder modelBuilder)
{
modelBuilder