diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs index c09ae3aa10f4233b77cc2c99e2c06fc9983619bb..03da9e33c3c945e23cb50a79626762132a04d19d 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs @@ -13,6 +13,7 @@ namespace Tsi1.DataLayer.Entities Sections = new HashSet<Section>(); Communications = new HashSet<Communication>(); Activities = new HashSet<Activity>(); + StudentCourseResults = new HashSet<StudentCourseResult>(); } public int Id { get; set; } @@ -28,5 +29,7 @@ namespace Tsi1.DataLayer.Entities public ICollection<Communication> Communications { get; set; } public ICollection<Activity> Activities { get; set; } + + public ICollection<StudentCourseResult> StudentCourseResults { get; set; } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs index cccbc18bb41494afc8179a2528185e114bd8707f..e6c50ad43e7753ca7d1cb316340e03696d4de4b5 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs @@ -11,6 +11,7 @@ namespace Tsi1.DataLayer.Entities StudentCourses = new HashSet<StudentCourse>(); EvaluationInscriptions = new HashSet<EvaluationInscription>(); Submissions = new HashSet<Submission>(); + StudentCourseResults = new HashSet<StudentCourseResult>(); } public int Id { get; set; } @@ -26,5 +27,7 @@ namespace Tsi1.DataLayer.Entities public ICollection<EvaluationInscription> EvaluationInscriptions { get; set; } public ICollection<Submission> Submissions { get; set; } + + public ICollection<StudentCourseResult> StudentCourseResults { get; set; } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/StudentCourseResult.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/StudentCourseResult.cs new file mode 100644 index 0000000000000000000000000000000000000000..443110aa1aaad0fd15d0310bcd0ed472553c7dcf --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/StudentCourseResult.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class StudentCourseResult + { + public int Id { get; set; } + + public int Result { get; set; } + + public DateTime Date { get; set; } + + public int StudentId { get; set; } + public int CourseId { get; set; } + + public Student Student { get; set; } + public Course Course { get; set; } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/StudentCourseResultConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/StudentCourseResultConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..6149b85d8322b2b8b69522ee25549c25b341a3c7 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/StudentCourseResultConfiguration.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System; +using System.Collections.Generic; +using System.Text; +using Tsi1.DataLayer.Entities; + +namespace Tsi1.DataLayer.EntityConfiguration +{ + public class StudentCourseResultConfiguration : IEntityTypeConfiguration<StudentCourseResult> + { + public void Configure(EntityTypeBuilder<StudentCourseResult> builder) + { + builder.HasKey(x => x.Id); + + builder.Property(x => x.Result) + .IsRequired() + .HasColumnType("integer"); + + builder.Property(x => x.Date) + .IsRequired(); + + builder.HasOne(x => x.Course) + .WithMany(x => x.StudentCourseResults) + .HasForeignKey(x => x.CourseId); + + builder.HasOne(x => x.Student) + .WithMany(x => x.StudentCourseResults) + .HasForeignKey(x => x.StudentId); + } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs b/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs index cef2ed04e914bc9f2a34468270426eb90e72e347..50967e83b4f85eeeb398e2ec4a6df1bf48e55ddd 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs @@ -39,6 +39,7 @@ namespace Tsi1.DataLayer public DbSet<EvaluationInscription> EvaluationInscriptions { get; set; } public DbSet<Submission> Submissions { get; set; } public DbSet<EvaluationType> EvaluationTypes { get; set; } + public DbSet<StudentCourseResult> StudentCourseResults { get; set; } @@ -77,6 +78,7 @@ namespace Tsi1.DataLayer modelBuilder.ApplyConfiguration(new EvaluationInscriptionConfiguration()); modelBuilder.ApplyConfiguration(new SubmissionConfiguration()); modelBuilder.ApplyConfiguration(new EvaluationTypeConfiguration()); + modelBuilder.ApplyConfiguration(new StudentCourseResultConfiguration()); } } }