Add a Persistence layer (#3)

Reviewed-on: #3
This commit is contained in:
Polianin Nikita 2024-01-08 23:22:35 +03:00
commit 6f5a84f645
23 changed files with 503 additions and 1 deletions

View File

@ -17,7 +17,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution",
README.md = README.md README.md = README.md
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "Application\Application.csproj", "{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "Application\Application.csproj", "{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}"
ProjectSection(ProjectDependencies) = postProject
{C27FB5CD-6A70-4FB2-847A-847B34806902} = {C27FB5CD-6A70-4FB2-847A-847B34806902}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "Persistence\Persistence.csproj", "{4C1E558F-633F-438E-AC3A-61CDDED917C5}"
ProjectSection(ProjectDependencies) = postProject
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4} = {E7F0A4D4-B032-4BB9-9526-1AF688F341A4}
EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -33,6 +41,14 @@ Global
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.ActiveCfg = Release|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.Build.0 = Release|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.Build.0 = Release|Any CPU
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Release|Any CPU.Build.0 = Release|Any CPU
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,17 @@
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 CampusDbContext(DbContextOptions<CampusDbContext> options) : DbContext(options), ICampusDbContext
{
public DbSet<Campus> Campuses { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new CampusConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 DayDbContext(DbContextOptions<DayDbContext> options) : DbContext(options), IDayDbContext
{
public DbSet<Day> Days { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new DayConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 FacultyDbContext(DbContextOptions<FacultyDbContext> options) : DbContext(options), IFacultyDbContext
{
public DbSet<Faculty> Faculties { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 GroupDbContext(DbContextOptions<GroupDbContext> options) : DbContext(options), IGroupDbContext
{
public DbSet<Group> Groups { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new GroupConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 LectureHallDbContext(DbContextOptions<LectureHallDbContext> options) : DbContext(options), ILectureHallDbContext
{
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 LessonDbContext(DbContextOptions<LessonDbContext> options) : DbContext(options), ILessonDbContext
{
public DbSet<Lesson> Lessons { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new LessonConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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);
}
}

View File

@ -0,0 +1,17 @@
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 ProfessorDbContext(DbContextOptions<ProfessorDbContext> options) : DbContext(options), IProfessorDbContext
{
public DbSet<Professor> Professors { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 ProfessorToLessonDbContext(DbContextOptions<ProfessorToLessonDbContext> options) : DbContext(options), IProfessorToLessonDbContext
{
public DbSet<ProfessorToLesson> ProfessorToLessons { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new ProfessorToLessonConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,17 @@
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 TypeOfOccupationDbContext(DbContextOptions<TypeOfOccupationDbContext> options) : DbContext(options), ITypeOfOccupationDbContext
{
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class CampusConfiguration : IEntityTypeConfiguration<Campus>
{
public void Configure(EntityTypeBuilder<Campus> builder)
{
builder.ToTable(nameof(Campus));
builder.HasKey(c => c.Id);
builder.HasIndex(c => c.Id).IsUnique();
builder.Property(c => c.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(c => c.Address).HasColumnType("TEXT").HasMaxLength(512);
builder.Property(c => c.CodeName).HasColumnType("TEXT").IsRequired().HasMaxLength(16);
builder.Property(c => c.FullName).HasColumnType("TEXT").HasMaxLength(256);
}
}

View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class DayConfiguration : IEntityTypeConfiguration<Day>
{
public void Configure(EntityTypeBuilder<Day> builder)
{
builder.ToTable(nameof(Day));
builder.HasKey(d => d.Id);
builder.HasIndex(d => d.Id).IsUnique();
builder.Property(d => d.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(d => d.PairNumber).HasColumnType("INTEGER").IsRequired();
builder.Property(d => d.Index).HasColumnType("INTEGER").IsRequired();
builder.Property(d => d.GroupId).HasColumnType("INTEGER").IsRequired();
builder.Property(d => d.LessonId).HasColumnType("INTEGER").IsRequired();
builder
.HasOne(d => d.Group)
.WithMany(g => g.Days)
.HasForeignKey(d => d.GroupId)
.OnDelete(DeleteBehavior.Restrict);
builder
.HasOne(d => d.Lesson)
.WithOne(l => l.Day)
.HasForeignKey<Day>(d => d.LessonId)
.OnDelete(DeleteBehavior.Restrict);
}
}

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class FacultyConfiguration : IEntityTypeConfiguration<Faculty>
{
public void Configure(EntityTypeBuilder<Faculty> builder)
{
builder.ToTable(nameof(Faculty));
builder.HasKey(f => f.Id);
builder.HasIndex(f => f.Id).IsUnique();
builder.Property(f => f.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(f => f.Name).HasColumnType("TEXT").IsRequired().HasMaxLength(256);
builder
.HasOne(f => f.Campus)
.WithMany(c => c.Faculties)
.HasForeignKey(c => c.CampusId)
.OnDelete(DeleteBehavior.SetNull);
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class GroupConfiguration : IEntityTypeConfiguration<Group>
{
public void Configure(EntityTypeBuilder<Group> builder)
{
builder.ToTable(nameof(Group));
builder.HasKey(g => g.Id);
builder.HasIndex(g => g.Id).IsUnique();
builder.Property(g => g.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(g => g.FacultyId).HasColumnType("INTEGER").IsRequired();
builder.Property(g => g.Name).HasColumnType("TEXT").IsRequired().HasMaxLength(64);
builder
.HasOne(g => g.Faculty)
.WithMany(u => u.Groups)
.HasForeignKey(d => d.FacultyId)
.OnDelete(DeleteBehavior.Restrict);
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class LectureHallConfiguration : IEntityTypeConfiguration<LectureHall>
{
public void Configure(EntityTypeBuilder<LectureHall> builder)
{
builder.ToTable(nameof(LectureHall));
builder.HasKey(l => l.Id);
builder.HasIndex(l => l.Id).IsUnique();
builder.Property(l => l.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.CampusId).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.Name).HasColumnType("TEXT").IsRequired().HasMaxLength(64);
builder
.HasOne(l => l.Campus)
.WithMany(c => c.LectureHalls)
.HasForeignKey(d => d.CampusId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class LessonConfiguration : IEntityTypeConfiguration<Lesson>
{
public void Configure(EntityTypeBuilder<Lesson> builder)
{
builder.ToTable(nameof(Lesson));
builder.HasKey(l => l.Id);
builder.HasIndex(l => l.Id).IsUnique();
builder.Property(l => l.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.Discipline).HasColumnType("TEXT").IsRequired().HasMaxLength(256);
builder.Property(l => l.IsEven).HasColumnType("BIT").IsRequired();
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class LessonToTypeOfOccupationConfiguration : IEntityTypeConfiguration<LessonToTypeOfOccupation>
{
public void Configure(EntityTypeBuilder<LessonToTypeOfOccupation> builder)
{
builder.ToTable(nameof(LessonToTypeOfOccupation));
builder.HasKey(l => l.Id);
builder.HasIndex(l => l.Id).IsUnique();
builder.Property(l => l.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.LessonId).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
builder
.HasOne(l => l.Lesson)
.WithMany(l => l.TypeOfOccupations)
.HasForeignKey(l => l.LessonId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(l => l.TypeOfOccupation)
.WithMany(t => t.Lessons)
.HasForeignKey(l => l.TypeOfOccupationId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class ProfessorConfiguration : IEntityTypeConfiguration<Professor>
{
public void Configure(EntityTypeBuilder<Professor> builder)
{
builder.ToTable(nameof(Professor));
builder.HasKey(p => p.Id);
builder.HasIndex(p => p.Id).IsUnique();
builder.Property(p => p.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(p => p.Name).HasColumnType("TEXT").IsRequired();
builder.Property(p => p.AltName).HasColumnType("TEXT");
}
}

View File

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class ProfessorToLessonConfiguration : IEntityTypeConfiguration<ProfessorToLesson>
{
public void Configure(EntityTypeBuilder<ProfessorToLesson> builder)
{
builder.ToTable(nameof(ProfessorToLesson));
builder.HasKey(p => p.Id);
builder.HasIndex(p => p.Id).IsUnique();
builder.Property(p => p.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.LinkToMeet).HasColumnType("TEXT").HasMaxLength(512);
builder.Property(p => p.LessonId).HasColumnType("INTEGER").IsRequired();
builder.Property(p => p.ProfessorId).HasColumnType("INTEGER");
builder.Property(l => l.LectureHallId).HasColumnType("INTEGER");
builder
.HasOne(p => p.LectureHall)
.WithMany(l => l.ProfessorToLessons)
.HasForeignKey(l => l.LectureHallId)
.OnDelete(DeleteBehavior.SetNull);
builder
.HasOne(p => p.Lesson)
.WithMany(l => l.ProfessorToLesson)
.HasForeignKey(p => p.LessonId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(p => p.Professor)
.WithMany(p => p.ProfessorToLesson)
.HasForeignKey(p => p.ProfessorId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
public class TypeOfOccupationConfiguration : IEntityTypeConfiguration<TypeOfOccupation>
{
public void Configure(EntityTypeBuilder<TypeOfOccupation> builder)
{
builder.ToTable(nameof(TypeOfOccupation));
builder.HasKey(t => t.Id);
builder.HasIndex(t => t.Id).IsUnique();
builder.Property(t => t.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(t => t.FullName).HasColumnType("TEXT").HasMaxLength(64);
builder.Property(t => t.ShortName).HasColumnType("TEXT").IsRequired().HasMaxLength(16);
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.0.0-a0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<AssemblyName>Mirea.Api.DataAccess.Persistence</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using Mirea.Api.DataAccess.Domain.Schedule;
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
namespace Mirea.Api.DataAccess.Persistence;
public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(options)
{
public DbSet<Day> Days { get; set; } = null!;
public DbSet<Group> Groups { get; set; } = null!;
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
public DbSet<Lesson> Lessons { get; set; } = null!;
public DbSet<Professor> Professors { 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)
{
modelBuilder.ApplyConfiguration(new DayConfiguration());
modelBuilder.ApplyConfiguration(new GroupConfiguration());
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
modelBuilder.ApplyConfiguration(new LessonConfiguration());
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
modelBuilder.ApplyConfiguration(new CampusConfiguration());
modelBuilder.ApplyConfiguration(new ProfessorToLessonConfiguration());
modelBuilder.ApplyConfiguration(new LessonToTypeOfOccupationConfiguration());
base.OnModelCreating(modelBuilder);
}
}