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
30 changes: 15 additions & 15 deletions exercise.wwwapi/Data/ModelSeeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
);
}
Expand All @@ -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"
}
);
Expand All @@ -445,39 +445,39 @@ 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)
},
new Note
{
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)
},
new Note
{
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)
},
new Note
{
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)
},
new Note
{
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)
}
Expand Down
26 changes: 26 additions & 0 deletions exercise.wwwapi/Models/CourseModule.cs
Original file line number Diff line number Diff line change
@@ -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; }

}
8 changes: 6 additions & 2 deletions exercise.wwwapi/Models/Exercise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)")]
Expand Down
2 changes: 1 addition & 1 deletion exercise.wwwapi/Models/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
6 changes: 3 additions & 3 deletions exercise.wwwapi/Models/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exercise> Exercises { get; set; } = new List<Exercise>();
}
39 changes: 39 additions & 0 deletions exercise.wwwapi/Models/UserExercise.cs
Original file line number Diff line number Diff line change
@@ -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; }

}