diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs new file mode 100644 index 0000000000000000000000000000000000000000..4a0ad033eb9e53de2188c8f90652f206fe309ef3 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Activity.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class Activity + { + public Activity() + { + Attendances = new HashSet<Attendance>(); + } + + public int Id { get; set; } + + public string Name { get; set; } + + public bool IsVideoConference { get; set; } + + public int CourseId { get; set; } + + public Course Course { get; set; } + + public ICollection<Attendance> Attendances { get; set; } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Attendance.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Attendance.cs new file mode 100644 index 0000000000000000000000000000000000000000..4c2257aefd62a77cafff5ba058d7b50a4b0de595 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Attendance.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tsi1.DataLayer.Entities +{ + public class Attendance + { + public int Id { get; set; } + + public DateTime Date { get; set; } + + public int UserId { get; set; } + + public int ActivityId { get; set; } + + public User User { get; set; } + + public Activity Activity { get; set; } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs index f7efedf6afcfa34052001aa393799e23773d8eb3..c09ae3aa10f4233b77cc2c99e2c06fc9983619bb 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/Course.cs @@ -12,6 +12,7 @@ namespace Tsi1.DataLayer.Entities ProfessorCourses = new HashSet<ProfessorCourse>(); Sections = new HashSet<Section>(); Communications = new HashSet<Communication>(); + Activities = new HashSet<Activity>(); } public int Id { get; set; } @@ -25,5 +26,7 @@ namespace Tsi1.DataLayer.Entities public ICollection<Section> Sections { get; set; } public ICollection<Communication> Communications { get; set; } + + public ICollection<Activity> Activities { get; set; } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/Entities/User.cs b/Tsi1.Api/Tsi1.DataLayer/Entities/User.cs index e3656322faa236d10a84b18c1fc4985cb240280d..fb5427eb77f6c5ea543ea0b1bdb210617d8631ff 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Entities/User.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Entities/User.cs @@ -12,6 +12,7 @@ namespace Tsi1.DataLayer.Entities PostMessages = new HashSet<PostMessage>(); ForumUsers = new HashSet<ForumUser>(); SurveyResponses = new HashSet<SurveyResponse>(); + Attendances = new HashSet<Attendance>(); } public int Id { get; set; } @@ -43,5 +44,6 @@ namespace Tsi1.DataLayer.Entities public ICollection<PostMessage> PostMessages { get; set; } public ICollection<ForumUser> ForumUsers { get; set; } public ICollection<SurveyResponse> SurveyResponses { get; set; } + public ICollection<Attendance> Attendances { get; set; } } } diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/ActivityConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/ActivityConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..bb240989a2fd94ea21c55cf70fe94ffb6f144f78 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/ActivityConfiguration.cs @@ -0,0 +1,25 @@ +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 ActivityConfiguration : IEntityTypeConfiguration<Activity> + { + public void Configure(EntityTypeBuilder<Activity> builder) + { + builder.HasKey(x => x.Id); + + builder.Property(x => x.Name) + .IsRequired() + .HasColumnType("character varying(50)"); + + builder.HasOne(x => x.Course) + .WithMany(x => x.Activities) + .HasForeignKey(x => x.CourseId); + } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/AttendanceConfiguration.cs b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/AttendanceConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..d8e88def61900fd6ef56bd068896877b4b53d0e0 --- /dev/null +++ b/Tsi1.Api/Tsi1.DataLayer/EntityConfiguration/AttendanceConfiguration.cs @@ -0,0 +1,25 @@ +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 AttendanceConfiguration : IEntityTypeConfiguration<Attendance> + { + public void Configure(EntityTypeBuilder<Attendance> builder) + { + builder.HasKey(x => x.Id); + + builder.HasOne(x => x.User) + .WithMany(x => x.Attendances) + .HasForeignKey(x => x.UserId); + + builder.HasOne(x => x.Activity) + .WithMany(x => x.Attendances) + .HasForeignKey(x => x.ActivityId); + } + } +} diff --git a/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs b/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs index b35e7b2f0949cb8086fb134fe60f1d66e79e658b..bda60bbf54d151e5d680b5a78772624a78456bfb 100644 --- a/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs +++ b/Tsi1.Api/Tsi1.DataLayer/Tsi1Context.cs @@ -32,8 +32,9 @@ namespace Tsi1.DataLayer public DbSet<SurveyQuestion> SurveyQuestions { get; set; } public DbSet<SurveyResponse> SurveyResponses { get; set; } public DbSet<AnswerOption> AnswerOptions { get; set; } - public DbSet<Communication> Communications { get; set; } + public DbSet<Activity> Activities { get; set; } + public DbSet<Attendance> Attendances { get; set; } @@ -65,6 +66,8 @@ namespace Tsi1.DataLayer modelBuilder.ApplyConfiguration(new SurveyResponseConfiguration()); modelBuilder.ApplyConfiguration(new AnswerOptionConfiguration()); modelBuilder.ApplyConfiguration(new CommunicationConfiguration()); + modelBuilder.ApplyConfiguration(new ActivityConfiguration()); + modelBuilder.ApplyConfiguration(new AttendanceConfiguration()); } } }