refactor: fix database contexts
This commit is contained in:
parent
bd3a11486d
commit
e7c05b4a68
@ -3,7 +3,7 @@ using Mirea.Api.DataAccess.Domain.Schedule;
|
|||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
|
|
||||||
public interface IDayDbContext : IDbContextBase
|
public interface IDisciplineDbContext : IDbContextBase
|
||||||
{
|
{
|
||||||
DbSet<Day> Days { get; set; }
|
DbSet<Discipline> Disciplines { get; set; }
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ using Mirea.Api.DataAccess.Domain.Schedule;
|
|||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
|
|
||||||
public interface IProfessorToLessonDbContext : IDbContextBase
|
public interface ILessonAssociationDbContext : IDbContextBase
|
||||||
{
|
{
|
||||||
DbSet<ProfessorToLesson> ProfessorToLessons { get; set; }
|
DbSet<LessonAssociation> LessonAssociations { get; set; }
|
||||||
}
|
}
|
@ -1,9 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
|
||||||
|
|
||||||
public interface ILessonToTypeOfOccupationDbContext : IDbContextBase
|
|
||||||
{
|
|
||||||
DbSet<LessonToTypeOfOccupation> LessonToTypeOfOccupations { get; set; }
|
|
||||||
}
|
|
@ -5,13 +5,13 @@ using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
|||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class DayDbContext(DbContextOptions<DayDbContext> options) : DbContext(options), IDayDbContext
|
public class DisciplineDbContext(DbContextOptions<DisciplineDbContext> options) : DbContext(options), IDisciplineDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Day> Days { get; set; } = null!;
|
public DbSet<Discipline> Disciplines { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new DayConfiguration());
|
modelBuilder.ApplyConfiguration(new DisciplineConfiguration());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,13 +5,13 @@ using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
|||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class ProfessorToLessonDbContext(DbContextOptions<ProfessorToLessonDbContext> options) : DbContext(options), IProfessorToLessonDbContext
|
public class LessonAssociationDbContext(DbContextOptions<LessonAssociationDbContext> options) : DbContext(options), ILessonAssociationDbContext
|
||||||
{
|
{
|
||||||
public DbSet<ProfessorToLesson> ProfessorToLessons { get; set; } = null!;
|
public DbSet<LessonAssociation> LessonAssociations { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new ProfessorToLessonConfiguration());
|
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
|
||||||
|
|
||||||
public class LessonToTypeOfOccupationDbContext(DbContextOptions<LessonToTypeOfOccupationDbContext> options) : DbContext(options), ILessonToTypeOfOccupationDbContext
|
|
||||||
{
|
|
||||||
public DbSet<LessonToTypeOfOccupation> LessonToTypeOfOccupations { get; set; } = null!;
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
modelBuilder.ApplyConfiguration(new LessonToTypeOfOccupationConfiguration());
|
|
||||||
base.OnModelCreating(modelBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,29 +6,27 @@ namespace Mirea.Api.DataAccess.Persistence;
|
|||||||
|
|
||||||
public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(options)
|
public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
public DbSet<Day> Days { get; set; } = null!;
|
public DbSet<Campus> Campuses { get; set; } = null!;
|
||||||
|
public DbSet<Discipline> Disciplines { get; set; } = null!;
|
||||||
|
public DbSet<Faculty> Faculties { get; set; } = null!;
|
||||||
public DbSet<Group> Groups { get; set; } = null!;
|
public DbSet<Group> Groups { get; set; } = null!;
|
||||||
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
|
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
|
||||||
|
public DbSet<LessonAssociation> LessonAssociations { get; set; } = null!;
|
||||||
public DbSet<Lesson> Lessons { get; set; } = null!;
|
public DbSet<Lesson> Lessons { get; set; } = null!;
|
||||||
public DbSet<Professor> Professors { get; set; } = null!;
|
public DbSet<Professor> Professors { get; set; } = null!;
|
||||||
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
||||||
public DbSet<Faculty> Faculties { get; set; } = null!;
|
|
||||||
public DbSet<Campus> Campuses { get; set; } = null!;
|
|
||||||
public DbSet<ProfessorToLesson> ProfessorToLessons { get; set; } = null!;
|
|
||||||
public DbSet<LessonToTypeOfOccupation> LessonToTypeOfOccupations { get; set; } = null!;
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new DayConfiguration());
|
modelBuilder.ApplyConfiguration(new CampusConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new DisciplineConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new GroupConfiguration());
|
modelBuilder.ApplyConfiguration(new GroupConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
|
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new LessonConfiguration());
|
modelBuilder.ApplyConfiguration(new LessonConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
|
|
||||||
modelBuilder.ApplyConfiguration(new CampusConfiguration());
|
|
||||||
modelBuilder.ApplyConfiguration(new ProfessorToLessonConfiguration());
|
|
||||||
modelBuilder.ApplyConfiguration(new LessonToTypeOfOccupationConfiguration());
|
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user