| | 1 | | using Syki.Back.Features.Student.CreateStudentEnrollment; |
| | 2 | |
|
| | 3 | | namespace Syki.Back.Features.Academic.CreateClass; |
| | 4 | |
|
| | 5 | | public class ClassConfig : IEntityTypeConfiguration<Class> |
| | 6 | | { |
| | 7 | | public void Configure(EntityTypeBuilder<Class> @class) |
| | 8 | | { |
| 2 | 9 | | @class.ToTable("classes"); |
| | 10 | |
|
| 2 | 11 | | @class.HasKey(c => c.Id); |
| 2 | 12 | | @class.Property(c => c.Id).ValueGeneratedNever(); |
| | 13 | |
|
| 2 | 14 | | @class.HasOne(c => c.Teacher) |
| 2 | 15 | | .WithMany() |
| 2 | 16 | | .HasForeignKey(c => c.TeacherId); |
| | 17 | |
|
| 2 | 18 | | @class.HasOne(c => c.Discipline) |
| 2 | 19 | | .WithMany() |
| 2 | 20 | | .HasForeignKey(c => c.DisciplineId); |
| | 21 | |
|
| 2 | 22 | | @class.HasMany(c => c.Schedules) |
| 2 | 23 | | .WithOne() |
| 2 | 24 | | .HasForeignKey(s => s.ClassId); |
| | 25 | |
|
| 2 | 26 | | @class.HasMany(c => c.Lessons) |
| 2 | 27 | | .WithOne() |
| 2 | 28 | | .HasForeignKey(l => l.ClassId); |
| | 29 | |
|
| 2 | 30 | | @class.HasOne(c => c.Period) |
| 2 | 31 | | .WithMany() |
| 2 | 32 | | .HasForeignKey(c => new { c.PeriodId, c.InstitutionId }); |
| | 33 | |
|
| 2 | 34 | | @class.HasMany(c => c.ExamGrades) |
| 2 | 35 | | .WithOne() |
| 2 | 36 | | .HasForeignKey(eg => eg.ClassId); |
| | 37 | |
|
| 2 | 38 | | @class.HasMany(c => c.Students) |
| 2 | 39 | | .WithMany() |
| 2 | 40 | | .UsingEntity<ClassStudent>(); |
| | 41 | |
|
| 2 | 42 | | @class.Ignore(c => c.FillRatio); |
| 2 | 43 | | } |
| | 44 | | } |