Skip to content
Snippets Groups Projects
Commit 6a06dd0e authored by esantangelo's avatar esantangelo
Browse files

entities and configuration

parent 13ca6236
No related branches found
No related tags found
1 merge request!43Feature/results
......@@ -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; }
}
}
......@@ -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; }
}
}
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; }
}
}
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);
}
}
}
......@@ -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());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment