feat: add configuration files
This commit is contained in:
parent
40279ab2b8
commit
84214e38cc
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user