diff --git a/exercise.wwwapi/Data/ModelSeeder.cs b/exercise.wwwapi/Data/ModelSeeder.cs index 2fd0837..e04192f 100644 --- a/exercise.wwwapi/Data/ModelSeeder.cs +++ b/exercise.wwwapi/Data/ModelSeeder.cs @@ -369,31 +369,31 @@ private static void SeedUnits(ref ModelBuilder modelBuilder) { Id = 1, ModuleId = 1, - Title = "Module 1", + Name = "Module 1", }, new Unit { Id = 2, ModuleId = 2, - Title = "Module 2", + Name = "Module 2", }, new Unit { Id = 3, ModuleId = 3, - Title = "Module 3", + Name = "Module 3", }, new Unit { Id = 4, ModuleId = 4, - Title = "Module 4", + Name = "Module 4", }, new Unit { Id = 5, ModuleId = 5, - Title = "Module 5", + Name = "Module 5", } ); } @@ -405,35 +405,35 @@ private static void SeedExercises(ref ModelBuilder modelBuilder) { Id = 1, UnitId = 1, - Title = "Exercise 1", + Name = "Exercise 1", Description = "Exercise 1 description" }, new Exercise { Id = 2, UnitId = 2, - Title = "Exercise 2", + Name = "Exercise 2", Description = "Exercise 2 description" }, new Exercise { Id = 3, UnitId = 3, - Title = "Exercise 3", + Name = "Exercise 3", Description = "Exercise 3 description" }, new Exercise { Id = 4, UnitId = 4, - Title = "Exercise 4", + Name = "Exercise 4", Description = "Exercise 4 description" }, new Exercise { Id = 5, UnitId = 5, - Title = "Exercise 5", + Name = "Exercise 5", Description = "Exercise 5 description" } ); @@ -445,7 +445,7 @@ private static void SeedNotes(ref ModelBuilder modelBuilder) { Id = 1, UserId = 1, - Title = "Title Note 1", + Title = "Name Note 1", Content = "note1note1 note1 note1 content", CreatedAt = new DateTime(2025, 9, 5, 11, 2, 0, DateTimeKind.Utc) }, @@ -453,7 +453,7 @@ private static void SeedNotes(ref ModelBuilder modelBuilder) { Id = 2, UserId = 2, - Title = "Title Note 2", + Title = "Name Note 2", Content = "note2 note2 note2 note2 content", CreatedAt = new DateTime(2025, 9, 5, 11, 2, 0, DateTimeKind.Utc) }, @@ -461,7 +461,7 @@ private static void SeedNotes(ref ModelBuilder modelBuilder) { Id = 3, UserId = 3, - Title = "Title Note 3", + Title = "Name Note 3", Content = "note3 note3 note3 note3 content", CreatedAt = new DateTime(2025, 9, 5, 11, 2, 0, DateTimeKind.Utc) }, @@ -469,7 +469,7 @@ private static void SeedNotes(ref ModelBuilder modelBuilder) { Id = 4, UserId = 4, - Title = "Title Note 4", + Title = "Name Note 4", Content = "note4 note4 note4 note4 content", CreatedAt = new DateTime(2025, 9, 5, 11, 2, 0, DateTimeKind.Utc) }, @@ -477,7 +477,7 @@ private static void SeedNotes(ref ModelBuilder modelBuilder) { Id = 5, UserId = 4, - Title = "Title Note 5", + Title = "Name Note 5", Content = "note5 note5 note5 note5 content", CreatedAt = new DateTime(2025, 9, 5, 11, 2, 0, DateTimeKind.Utc) } diff --git a/exercise.wwwapi/Models/CourseModule.cs b/exercise.wwwapi/Models/CourseModule.cs new file mode 100644 index 0000000..1a1bb71 --- /dev/null +++ b/exercise.wwwapi/Models/CourseModule.cs @@ -0,0 +1,26 @@ +using exercise.wwwapi.Enums; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +namespace exercise.wwwapi.Models.UserInfo; + +[Table("Course_Module")] +public class CourseModule +{ + [Key] + [Column("id")] + public int Id { get; set; } + + [ForeignKey(nameof(Course))] + [Column("course_id")] + public int CourseId { get; set; } + + public Course Course { get; set; } + + [ForeignKey(nameof(Exercise))] + [Column("module_id")] + public int ModuleId { get; set; } + public Module Module { get; set; } + +} \ No newline at end of file diff --git a/exercise.wwwapi/Models/Exercise.cs b/exercise.wwwapi/Models/Exercise.cs index e28e99a..dc0a47f 100644 --- a/exercise.wwwapi/Models/Exercise.cs +++ b/exercise.wwwapi/Models/Exercise.cs @@ -15,8 +15,12 @@ public class Exercise public int UnitId { get; set; } [Required] - [Column("title", TypeName = "varchar(100)")] - public string Title { get; set; } + [Column("name", TypeName = "varchar(100)")] + public string Name { get; set; } + + [Required] + [Column("github_link", TypeName = "varchar(200)")] + public string GitHubLink { get; set; } [Required] [Column("description", TypeName = "varchar(500)")] diff --git a/exercise.wwwapi/Models/Note.cs b/exercise.wwwapi/Models/Note.cs index 6d38bab..fb20b14 100644 --- a/exercise.wwwapi/Models/Note.cs +++ b/exercise.wwwapi/Models/Note.cs @@ -17,7 +17,7 @@ public class Note [JsonIgnore] public User User { get; set; } - [Column("title", TypeName = "varchar(1000)")] + [Column("title", TypeName = "varchar(100)")] public string Title { get; set; } [Column("content", TypeName = "varchar(1000)")] public string Content { get; set; } diff --git a/exercise.wwwapi/Models/Unit.cs b/exercise.wwwapi/Models/Unit.cs index d5cfa25..801d6c2 100644 --- a/exercise.wwwapi/Models/Unit.cs +++ b/exercise.wwwapi/Models/Unit.cs @@ -13,11 +13,11 @@ public class Unit [Column("module_id")] [ForeignKey(nameof(Module))] public int ModuleId { get; set; } + public Module Module { get; set; } [Required] - [Column("title")] - public string Title { get; set; } + [Column("name")] + public string Name { get; set; } - public Module Module { get; set; } public ICollection Exercises { get; set; } = new List(); } \ No newline at end of file diff --git a/exercise.wwwapi/Models/UserExercise.cs b/exercise.wwwapi/Models/UserExercise.cs new file mode 100644 index 0000000..4f5ab93 --- /dev/null +++ b/exercise.wwwapi/Models/UserExercise.cs @@ -0,0 +1,39 @@ +using exercise.wwwapi.Enums; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +namespace exercise.wwwapi.Models.UserInfo; + +[Table("User_Exercises")] +public class UserExercise +{ + [Key] + [Column("id")] + public int Id { get; set; } + + [Column("submission_link", TypeName = "varchar(200)")] + public string SubmissionLink { get; set; } + + [Column("submission_time", TypeName = "date")] + public DateTime TurnedIn { get; set; } + + [Column("grade", TypeName = "int")] + public Specialism Specialism { get; set; } + + [ForeignKey(nameof(User))] + [Column("user_id")] + public int UserId { get; set; } + + [JsonIgnore] + public User User { get; set; } + + [Column("submitted")] + public bool Submitted { get; set; } + + [ForeignKey(nameof(Exercise))] + [Column("exercise_id")] + public int ExerciseId { get; set; } + public Exercise Exercise { get; set; } + +} \ No newline at end of file