diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs index ca3a040ea1a657e30df7781e1c05307070495724..7a1bd8821c973b2637aa69f59160f1eff4b37a02 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs @@ -18,10 +18,14 @@ namespace Tsi1.DataLayer.Entities public bool IsVideoConference { get; set; } + public int? EvaluationId { get; set; } + public int CourseId { get; set; } public Course Course { get; set; } + public Evaluation Evaluation { get; set; } + public ICollection<Attendance> Attendances { get; set; } public ICollection<Grade> Grades { get; set; } diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Evaluation.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Evaluation.cs new file mode 100644 index 0000000000000000000000000000000000000000..aa1b5dcc436a82215c1abf121a4c15c093bf2b1a --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Evaluation.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class Evaluation + { + public Evaluation() + { + EvaluationInscriptions = new HashSet<EvaluationInscription>(); + Submissions = new HashSet<Submission>(); + } + public int Id { get; set; } + + public int EvaluationTypeId { get; set; } + + public bool IsCompleted { get; set; } + + public EvaluationType EvaluationType { get; set; } + + public ICollection<EvaluationInscription> EvaluationInscriptions { get; set; } + + public ICollection<Submission> Submissions { get; set; } + + + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/EvaluationInscription.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/EvaluationInscription.cs new file mode 100644 index 0000000000000000000000000000000000000000..05fe24a173606a5f50da2a1383fb040f1b97f1b9 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/EvaluationInscription.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class EvaluationInscription + { + public int EvaluationId { get; set; } + + public int StudentId { get; set; } + + public Evaluation Evaluation { get; set; } + + public Student Student { get; set; } + + public decimal Grade { get; set; } + + public bool HasAttended { get; set; } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/EvaluationType.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/EvaluationType.cs new file mode 100644 index 0000000000000000000000000000000000000000..5cb4e72e318527f1a68ba34fc5d1d1d5cf1af190 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/EvaluationType.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class EvaluationType + { + public int Id { get; set; } + + public string Name { get; set; } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/File.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/File.cs index ea3324a77bd99ec20579f7aee468186c3c4bd643..96aa71c3052c36e423e9500e47cb1b3974aba62f 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/File.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/File.cs @@ -10,6 +10,12 @@ namespace Tsi1.DataLayer.Entities public string Name { get; set; } public string Path { get; set; } + public bool IsSubmission { get; set; } + + public int? SubmissionId { get; set; } + + public Submission Submission { get; set; } + public SectionItem SectionItem { get; set; } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs index 866c51651239ad1b38ce0ee23e6ba6002ccc24e6..cc7772d5bad7a1b931c68d25a98aee71cb3a6ffe 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Student.cs @@ -9,7 +9,9 @@ namespace Tsi1.DataLayer.Entities public Student() { StudentCourses = new HashSet<StudentCourse>(); + EvaluationInscriptions = new HashSet<EvaluationInscription>(); Grades = new HashSet<Grade>(); + Submissions = new HashSet<Submission>(); } public int Id { get; set; } @@ -25,5 +27,9 @@ namespace Tsi1.DataLayer.Entities public ICollection<StudentCourse> StudentCourses { get; set; } public ICollection<Grade> Grades { get; set; } + + public ICollection<EvaluationInscription> EvaluationInscriptions { get; set; } + + public ICollection<Submission> Submissions { get; set; } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Submission.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Submission.cs new file mode 100644 index 0000000000000000000000000000000000000000..add00c5960efa17310fde743c37469ab8d5c5b57 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Submission.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class Submission + { + public int Id { get; set; } + + public int StudentId { get; set; } + + public int FileId { get; set; } + + public Student Student { get; set; } + + public File File { get; set; } + + public decimal Grade { get; set; } + + public bool IsCompleted { get; set; } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..0cfb7fe714008cf57af8910182f36af9a1f303a6 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationConfiguration.cs @@ -0,0 +1,17 @@ +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 EvaluationConfiguration : IEntityTypeConfiguration<Evaluation> + { + public void Configure(EntityTypeBuilder<Evaluation> builder) + { + builder.HasKey(x => x.Id); + } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationInscriptionConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationInscriptionConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..652d92bfe09e44f3601dc14f5d6d260b2af1a0e1 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationInscriptionConfiguration.cs @@ -0,0 +1,29 @@ +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 EvaluationInscriptionConfiguration : IEntityTypeConfiguration<EvaluationInscription> + { + public void Configure(EntityTypeBuilder<EvaluationInscription> builder) + { + builder.HasKey(x => new { x.EvaluationId, x.StudentId }); + + builder.Property(x => x.Grade) + .IsRequired() + .HasColumnType("decimal(5,2)"); + + builder.HasOne(x => x.Evaluation) + .WithMany(x => x.EvaluationInscriptions) + .HasForeignKey(x => x.EvaluationId); + + builder.HasOne(x => x.Student) + .WithMany(x => x.EvaluationInscriptions) + .HasForeignKey(x => x.StudentId); + } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationTypeConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationTypeConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..0406bf5260153bb65a851dcb884487a907813571 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/EvaluationTypeConfiguration.cs @@ -0,0 +1,24 @@ +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 EvaluationTypeConfiguration : IEntityTypeConfiguration<EvaluationType> + { + public void Configure(EntityTypeBuilder<EvaluationType> builder) + { + builder.HasKey(x => x.Id); + + builder.HasIndex(x => x.Name) + .IsUnique(); + + builder.Property(x => x.Name) + .IsRequired() + .HasColumnType("character varying(50)"); + } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/FileConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/FileConfiguration.cs index ee21323fe9a845cfc5d780b24877022c0b09b2c2..b32e46347a601a9f975364e4cc6f2c8a7848bc2a 100644 --- a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/FileConfiguration.cs +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/FileConfiguration.cs @@ -23,6 +23,10 @@ namespace Tsi1.DataLayer.EntityConfiguration builder.HasIndex(x => x.Path) .IsUnique(); + + builder.HasOne(x => x.Submission) + .WithOne(x => x.File) + .HasForeignKey<File>(x => x.SubmissionId); } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/SubmissionConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/SubmissionConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..7a4f33e1481a5eb383de12f5cd771f8177f31e2d --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/SubmissionConfiguration.cs @@ -0,0 +1,28 @@ +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 SubmissionConfiguration : IEntityTypeConfiguration<Submission> + { + public void Configure(EntityTypeBuilder<Submission> builder) + { + builder.HasKey(x => x.Id); + + builder.HasIndex(x => new { x.StudentId, x.FileId }) + .IsUnique(); + + builder.Property(x => x.Grade) + .IsRequired() + .HasColumnType("decimal(5,2)"); + + builder.HasOne(x => x.Student) + .WithMany(x => x.Submissions) + .HasForeignKey(x => x.StudentId); + } + } +}