Add Application configuration #11

Merged
Wesser merged 128 commits from feat/add-setup into release/v1.0.0 2024-06-01 07:35:30 +03:00
10 changed files with 261 additions and 0 deletions
Showing only changes of commit 04b6687181 - Show all commits

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.Mysql.Schedule;
public sealed 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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(c => c.Address).HasColumnType("VARCHAR(512)").HasMaxLength(512);
builder.Property(c => c.CodeName).HasColumnType("VARCHAR(16)").IsRequired().HasMaxLength(16);
builder.Property(c => c.FullName).HasColumnType("VARCHAR(256)").HasMaxLength(256);
}
}

View File

@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule;
public class DisciplineConfiguration : IEntityTypeConfiguration<Discipline>
{
public void Configure(EntityTypeBuilder<Discipline> builder)
{
builder.ToTable(nameof(Discipline));
builder.HasKey(d => d.Id);
builder.HasIndex(d => d.Id).IsUnique();
builder.Property(d => d.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(d => d.Name).HasColumnType("VARCHAR(256)").HasMaxLength(256).IsRequired();
}
}

View File

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(f => f.Name).HasColumnType("VARCHAR(256)").IsRequired().HasMaxLength(256);
builder.Property(f => f.CampusId).HasColumnType("INT");
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.Mysql.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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(g => g.FacultyId).HasColumnType("INT");
builder.Property(g => g.Name).HasColumnType("VARCHAR(64)").IsRequired().HasMaxLength(64);
builder
.HasOne(g => g.Faculty)
.WithMany(u => u.Groups)
.HasForeignKey(d => d.FacultyId)
.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.Mysql.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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.CampusId).HasColumnType("INT").IsRequired();
builder.Property(l => l.Name).HasColumnType("VARCHAR(64)").IsRequired().HasMaxLength(64);
builder
.HasOne(l => l.Campus)
.WithMany(c => c.LectureHalls)
.HasForeignKey(d => d.CampusId)
.OnDelete(DeleteBehavior.Restrict);
}
}

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule;
public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAssociation>
{
public void Configure(EntityTypeBuilder<LessonAssociation> builder)
{
builder.ToTable(nameof(LessonAssociation));
builder.HasKey(l => l.Id);
builder.HasIndex(l => l.Id).IsUnique();
builder.Property(l => l.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.LinkToMeet).HasColumnType("VARCHAR(512)").HasMaxLength(512);
builder.Property(l => l.LessonId).HasColumnType("INT").IsRequired();
builder.Property(l => l.ProfessorId).HasColumnType("INT");
builder.Property(l => l.LectureHallId).HasColumnType("INT");
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INT").IsRequired();
builder
.HasOne(l => l.Lesson)
.WithMany(d => d.LessonAssociations)
.HasForeignKey(l => l.LessonId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(l => l.Professor)
.WithMany(p => p.LessonAssociations)
.HasForeignKey(l => l.ProfessorId)
.OnDelete(DeleteBehavior.SetNull);
builder
.HasOne(l => l.LectureHall)
.WithMany(l => l.LessonAssociations)
.HasForeignKey(l => l.LectureHallId)
.OnDelete(DeleteBehavior.SetNull);
builder
.HasOne(l => l.TypeOfOccupation)
.WithMany(t => t.Lessons)
.HasForeignKey(d => d.TypeOfOccupationId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(l => l.IsEven).HasColumnType("BIT(1)").IsRequired();
builder.Property(l => l.DayOfWeek).HasColumnType("INT").IsRequired();
builder.Property(l => l.PairNumber).HasColumnType("INT").IsRequired();
builder.Property(l => l.IsExcludedWeeks).HasColumnType("BIT(1)");
builder.Property(l => l.GroupId).HasColumnType("INT").IsRequired();
builder.Property(l => l.DisciplineId).HasColumnType("INT").IsRequired();
builder
.HasOne(l => l.Group)
.WithMany(g => g.Lessons)
.HasForeignKey(d => d.GroupId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(l => l.Discipline)
.WithMany(d => d.Lessons)
.HasForeignKey(l => l.DisciplineId)
.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.Mysql.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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(p => p.Name).HasColumnType("VARCHAR").IsRequired();
builder.Property(p => p.AltName).HasColumnType("VARCHAR");
}
}

View File

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule;
public class SpecificWeekConfiguration : IEntityTypeConfiguration<SpecificWeek>
{
public void Configure(EntityTypeBuilder<SpecificWeek> builder)
{
builder.ToTable(nameof(SpecificWeek));
builder.HasKey(s => s.Id);
builder.HasIndex(s => s.Id).IsUnique();
builder.Property(s => s.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(s => s.WeekNumber).HasColumnType("INT").IsRequired();
builder.Property(s => s.LessonId).HasColumnType("INT").IsRequired();
builder
.HasOne(s => s.Lesson)
.WithMany(l => l.SpecificWeeks)
.HasForeignKey(s => s.LessonId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mirea.Api.DataAccess.Domain.Schedule;
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.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("INT").IsRequired().ValueGeneratedOnAdd();
builder.Property(t => t.ShortName).HasColumnType("VARCHAR").IsRequired().HasMaxLength(16);
}
}