Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions exercise.wwwapi/Models/Cohort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ public class Cohort
[Column("id")]
public int Id { get; set; }

[Column("course_id")]
[ForeignKey(nameof(Course))]
public int CourseId { get; set; }
public Course Course { get; set; }
public ICollection<User> Users { get; set; } = new List<User>();
[Column("cohort_number")]
public int CohortNumber { get; set; }

[Column("cohort_name", TypeName = "varchar(50)")]
public string CohortName { get; set; }

[Column("start_date", TypeName = "date")]
public DateTime StartDate { get; set; }

[Column("end_date", TypeName = "date"))]
public DateTime EndDate { get; set; }

public ICollection<CohortCourse> CohortCourse { get; set; } = new List<CohortCourse>();
}
29 changes: 29 additions & 0 deletions exercise.wwwapi/Models/Cohort_Course.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using exercise.wwwapi.Models.UserInfo;


namespace exercise.wwwapi.Models
{
[Table("cohort_course")]
public class CohortCourse
{
[Key]
[Column("id")]
public int Id { get; set; }

[ForeignKey(nameof(Cohort))]
[Column("cohort_id")]
public int CohortId { get; set; }

[ForeignKey(nameof(Course))]
[Column("course_id")]
public int CourseId { get; set; }

public Cohort Cohort { get; set; }
public Course Course { get; set; }



}
}
9 changes: 4 additions & 5 deletions exercise.wwwapi/Models/Course.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@

namespace exercise.wwwapi.Models;

[Table("course")]
[Table("courses")]
public class Course
{
[Key]
[Column("id")]
public int Id { get; set; }

[Required]
[Column("course_name", TypeName = "varchar(100)")]
public string CourseName { get; set; }
[Column("name", TypeName = "varchar(100)")]
public string Name { get; set; }

public ICollection<Module> Modules { get; set; } = new List<Module>();
public ICollection<Cohort> Cohorts { get; set; } = new List<Cohort>();
public ICollection<CohortCourse> CohortCourses { get; set; } = new List<CohortCourse>();
}
28 changes: 28 additions & 0 deletions exercise.wwwapi/Models/UserCC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using exercise.wwwapi.Models.UserInfo;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace exercise.wwwapi.Models
{
[Table("user_cc")]
public class UserCC
{
[Key]
[Column("id")]
public int Id { get; set; }

[ForeignKey(nameof(Course))]
[Column("course_id")]
public int CourseId { get; set; }

[ForeignKey(nameof(User))]
[Column("user_id")]

public int UserId { get; set; }

public Course Course { get; set; }

public User User { get; set; }

}
}