feat: add specific week to persistence
Some checks failed
.NET Test Pipeline / build-and-test (pull_request) Failing after 3m13s

This commit is contained in:
2024-05-19 11:52:56 +03:00
parent 628faf7e68
commit 97d2fae79e
7 changed files with 56 additions and 9 deletions

View File

@ -18,6 +18,8 @@ public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAss
builder.Property(l => l.LessonId).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.ProfessorId).HasColumnType("INTEGER");
builder.Property(l => l.LectureHallId).HasColumnType("INTEGER");
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
builder
.HasOne(l => l.Lesson)
@ -36,5 +38,11 @@ public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAss
.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

@ -16,24 +16,17 @@ public class LessonConfiguration : IEntityTypeConfiguration<Lesson>
builder.Property(l => l.IsEven).HasColumnType("BIT").IsRequired();
builder.Property(l => l.DayOfWeek).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.PairNumber).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.IsExcludedWeeks).HasColumnType("BOOLEAN");
builder.Property(l => l.GroupId).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
builder.Property(l => l.DisciplineId).HasColumnType("INTEGER").IsRequired();
builder
.HasOne(l => l.Group)
.WithMany(g => g.Lessons)
.HasForeignKey(d => d.GroupId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(l => l.TypeOfOccupation)
.WithMany(t => t.Lessons)
.HasForeignKey(d => d.TypeOfOccupationId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(l => l.Discipline)
.WithMany(d => d.Lessons)

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.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("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(s => s.WeekNumber).HasColumnType("INTEGER").IsRequired();
builder.Property(s => s.LessonId).HasColumnType("INTEGER").IsRequired();
builder
.HasOne(s => s.Lesson)
.WithMany(l => l.SpecificWeeks)
.HasForeignKey(s => s.LessonId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -14,6 +14,5 @@ public class TypeOfOccupationConfiguration : IEntityTypeConfiguration<TypeOfOccu
builder.Property(t => t.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
builder.Property(t => t.ShortName).HasColumnType("TEXT").IsRequired().HasMaxLength(16);
builder.Property(t => t.FullName).HasColumnType("TEXT").HasMaxLength(64);
}
}