Skip to content

Commit

Permalink
Add initial models for routes & QTS (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Oct 29, 2024
1 parent b8c8605 commit 2b42a46
Show file tree
Hide file tree
Showing 21 changed files with 6,595 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TeachingRecordSystem.Core.DataStore.Postgres.Models;

namespace TeachingRecordSystem.Core.DataStore.Postgres.Mappings;

public class CountryMapping : IEntityTypeConfiguration<Country>
{
public void Configure(EntityTypeBuilder<Country> builder)
{
builder.HasKey(c => c.CountryId);
builder.Property(c => c.CountryId).HasMaxLength(4);
builder.Property(c => c.Name).HasMaxLength(200);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TeachingRecordSystem.Core.DataStore.Postgres.Models;

namespace TeachingRecordSystem.Core.DataStore.Postgres.Mappings;

public class EarlyYearsTeacherStatusQualificationMapping : IEntityTypeConfiguration<EarlyYearsTeacherStatusQualification>
{
public void Configure(EntityTypeBuilder<EarlyYearsTeacherStatusQualification> builder)
{
builder.Property(q => q.AwardedDate).HasColumnName("awarded_date");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public void Configure(EntityTypeBuilder<Qualification> builder)
builder.HasKey(q => q.QualificationId);
builder.HasQueryFilter(q => EF.Property<DateTime?>(q, nameof(Qualification.DeletedOn)) == null);
builder.HasDiscriminator(q => q.QualificationType)
.HasValue<MandatoryQualification>(QualificationType.MandatoryQualification);
.HasValue<MandatoryQualification>(QualificationType.MandatoryQualification)
.HasValue<QualifiedTeacherStatusQualification>(QualificationType.QualifiedTeacherStatus)
.HasValue<EarlyYearsTeacherStatusQualification>(QualificationType.EarlyYearsTeacherStatus);
builder.HasOne<Person>(q => q.Person).WithMany(p => p.Qualifications).HasForeignKey(q => q.PersonId).HasConstraintName(Qualification.PersonForeignKeyName);
builder.HasIndex(q => q.PersonId);
builder.HasIndex(q => q.DqtQualificationId).HasFilter("dqt_qualification_id is not null").IsUnique();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TeachingRecordSystem.Core.DataStore.Postgres.Models;

namespace TeachingRecordSystem.Core.DataStore.Postgres.Mappings;

public class QualifiedTeacherStatusQualificationMapping : IEntityTypeConfiguration<QualifiedTeacherStatusQualification>
{
public void Configure(EntityTypeBuilder<QualifiedTeacherStatusQualification> builder)
{
builder.Property(q => q.AwardedDate).HasColumnName("awarded_date");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TeachingRecordSystem.Core.DataStore.Postgres.Models;

namespace TeachingRecordSystem.Core.DataStore.Postgres.Mappings;

public class RouteMapping : IEntityTypeConfiguration<Route>
{
public void Configure(EntityTypeBuilder<Route> builder)
{
builder.HasKey(r => r.RouteId);
builder.HasOne<Person>().WithMany(p => p.Routes).HasForeignKey(r => r.PersonId);
builder.HasOne<Qualification>(r => r.Qualification).WithOne(q => q.Route).HasForeignKey<Route>(r => r.QualificationId);
builder.HasOne<Country>().WithMany().HasForeignKey(r => r.CountryId);
builder.HasIndex(r => r.PersonId);
}
}
Loading

0 comments on commit 2b42a46

Please sign in to comment.