| | | 1 | | using Syki.Back.Domain.Campi; |
| | | 2 | | using Syki.Back.Commands.Domain.Classes; |
| | | 3 | | |
| | | 4 | | namespace Syki.Back.Database.Classes; |
| | | 5 | | |
| | | 6 | | public class ClassDbConfig : IEntityTypeConfiguration<Class> |
| | | 7 | | { |
| | | 8 | | public void Configure(EntityTypeBuilder<Class> entity) |
| | | 9 | | { |
| | 4 | 10 | | entity.ToTable("classes", DbSchemas.Syki); |
| | | 11 | | |
| | 4 | 12 | | entity.HasKey(e => e.Id); |
| | | 13 | | |
| | 4 | 14 | | entity.HasOne<Campus>() |
| | 4 | 15 | | .WithMany() |
| | 4 | 16 | | .HasForeignKey(e => e.CampusId); |
| | | 17 | | |
| | 4 | 18 | | entity.HasOne(e => e.Teacher) |
| | 4 | 19 | | .WithMany() |
| | 4 | 20 | | .HasForeignKey(e => e.TeacherId); |
| | | 21 | | |
| | 4 | 22 | | entity.HasOne(e => e.Discipline) |
| | 4 | 23 | | .WithMany() |
| | 4 | 24 | | .HasForeignKey(e => e.DisciplineId); |
| | | 25 | | |
| | 4 | 26 | | entity.HasMany(e => e.Schedules) |
| | 4 | 27 | | .WithOne() |
| | 4 | 28 | | .HasForeignKey(s => s.ClassId); |
| | | 29 | | |
| | 4 | 30 | | entity.HasMany(e => e.Lessons) |
| | 4 | 31 | | .WithOne(l => l.Class) |
| | 4 | 32 | | .HasForeignKey(l => l.ClassId); |
| | | 33 | | |
| | 4 | 34 | | entity.HasOne(e => e.Period) |
| | 4 | 35 | | .WithMany() |
| | 4 | 36 | | .HasPrincipalKey(p => new { p.Id, p.InstitutionId }) |
| | 4 | 37 | | .HasForeignKey(e => new { e.PeriodId, e.InstitutionId }); |
| | 4 | 38 | | } |
| | | 39 | | } |