From ecf4c00a4935e9cd43050671b0e8547e6a04f7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Gy=C3=B6rgy=20Gallik?= Date: Thu, 26 Sep 2024 22:27:37 +0200 Subject: [PATCH] feat: Profile button --- .../GradeManagement.Client.csproj | 1 + .../Layout/AppBar.razor | 34 +- .../Pages/Authentication.razor | 5 + .../GradeManagement.Client/Pages/Main.razor | 2 +- .../20240926195542_mig11.Designer.cs | 846 ++++++++++++++++++ .../Migrations/20240926195542_mig11.cs | 137 +++ .../GradeManagementDbContextModelSnapshot.cs | 83 ++ 7 files changed, 1102 insertions(+), 6 deletions(-) create mode 100644 grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.Designer.cs create mode 100644 grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.cs diff --git a/grade-management-new/GradeManagement.Client/GradeManagement.Client.csproj b/grade-management-new/GradeManagement.Client/GradeManagement.Client.csproj index ebd483be..9b901dab 100644 --- a/grade-management-new/GradeManagement.Client/GradeManagement.Client.csproj +++ b/grade-management-new/GradeManagement.Client/GradeManagement.Client.csproj @@ -13,6 +13,7 @@ + diff --git a/grade-management-new/GradeManagement.Client/Layout/AppBar.razor b/grade-management-new/GradeManagement.Client/Layout/AppBar.razor index 023da6bf..f34c066b 100644 --- a/grade-management-new/GradeManagement.Client/Layout/AppBar.razor +++ b/grade-management-new/GradeManagement.Client/Layout/AppBar.razor @@ -1,23 +1,31 @@ +@using System.IdentityModel.Tokens.Jwt @using Microsoft.AspNetCore.Components.WebAssembly.Authentication @inject SubjectService SubjectService @inject NavigationManager Navigation +@inject IAccessTokenProvider TokenProvider AHK Review UI - + @* *@ - + - + + + - + @UserName + + @EmailAddress + + Sign Out @@ -26,16 +34,32 @@ @code{ - private string UserProfilePictureUrl { get; set; } = "https://via.placeholder.com/40"; // Default placeholder private string UserName { get; set; } = "Loading..."; + private string EmailAddress { get; set; } = "Loading..."; + private string UserProfilePictureUrl { get; set; } = @"https://ui-avatars.com/api/?rounded=true&name=John+Doe"; // Default placeholder [Parameter] public Action DrawerToggle { get; set; } [Parameter] public bool DrawerOpened { get; set; } + private string ImageLinkGenerator(string name) => $"https://ui-avatars.com/api/?rounded=true&name={name}"; + protected override async Task OnInitializedAsync() { await SubjectService.LoadSubjects(); SubjectService.OnChange += StateHasChanged; + + var result = await TokenProvider.RequestAccessToken(); + if (result.TryGetToken(out var token)) + { + var handler = new JwtSecurityTokenHandler(); + var jwtToken = handler.ReadJwtToken(token.Value); + + // Extract user information from the token + UserName = jwtToken.Claims.FirstOrDefault(c => c.Type == "name")?.Value ?? "Unknown User"; + EmailAddress = jwtToken.Claims.FirstOrDefault(c => c.Type == "email")?.Value ?? "Unknown Email"; + UserProfilePictureUrl = ImageLinkGenerator(UserName); + StateHasChanged(); + } } private void SignOut() diff --git a/grade-management-new/GradeManagement.Client/Pages/Authentication.razor b/grade-management-new/GradeManagement.Client/Pages/Authentication.razor index 41e3409c..77fc7eb5 100644 --- a/grade-management-new/GradeManagement.Client/Pages/Authentication.razor +++ b/grade-management-new/GradeManagement.Client/Pages/Authentication.razor @@ -14,6 +14,11 @@ // Call backend for user data Navigation.NavigateTo("/"); } + + if (Action == "logout-callback") + { + Navigation.NavigateTo("/"); + } } } diff --git a/grade-management-new/GradeManagement.Client/Pages/Main.razor b/grade-management-new/GradeManagement.Client/Pages/Main.razor index 4c240cb0..23c23dd8 100644 --- a/grade-management-new/GradeManagement.Client/Pages/Main.razor +++ b/grade-management-new/GradeManagement.Client/Pages/Main.razor @@ -88,7 +88,7 @@ - + diff --git a/grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.Designer.cs b/grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.Designer.cs new file mode 100644 index 00000000..d984822a --- /dev/null +++ b/grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.Designer.cs @@ -0,0 +1,846 @@ +// +using System; +using GradeManagement.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace GradeManagement.Data.Migrations +{ + [DbContext(typeof(GradeManagementDbContext))] + [Migration("20240926195542_mig11")] + partial class mig11 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("GradeManagement.Data.Models.Assignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExerciseId") + .HasColumnType("bigint"); + + b.Property("GithubRepoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GithubRepoUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("StudentId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("StudentId"); + + b.ToTable("Assignment"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.AssignmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AssignmentId") + .HasColumnType("bigint"); + + b.Property("Date") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PullRequestId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("AssignmentId"); + + b.HasIndex("PullRequestId"); + + b.ToTable("AssignmentLog"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LanguageId") + .HasColumnType("bigint"); + + b.Property("MoodleCourseId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SemesterId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("LanguageId"); + + b.HasIndex("SemesterId"); + + b.HasIndex("SubjectId"); + + b.ToTable("Course"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Exercise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("bigint"); + + b.Property("GithubPrefix") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("dueDate") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Exercise"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Group"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.GroupStudent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("StudentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("StudentId"); + + b.ToTable("GroupStudent"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.GroupTeacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("UserId"); + + b.ToTable("GroupTeacher"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Language"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.PullRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AssignmentId") + .HasColumnType("bigint"); + + b.Property("BranchName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("OpeningDate") + .HasColumnType("datetimeoffset"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("TeacherId") + .HasColumnType("bigint"); + + b.Property("Url") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AssignmentId"); + + b.HasIndex("TeacherId"); + + b.ToTable("PullRequest"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Score", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedDate") + .HasColumnType("datetimeoffset"); + + b.Property("IsApproved") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PullRequestId") + .HasColumnType("bigint"); + + b.Property("ScoreTypeId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("TeacherId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PullRequestId"); + + b.HasIndex("ScoreTypeId"); + + b.HasIndex("TeacherId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.ScoreType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ScoreType"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.ScoreTypeExercise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExerciseId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("ScoreId") + .HasColumnType("bigint"); + + b.Property("ScoreTypeId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("ScoreId"); + + b.HasIndex("ScoreTypeId"); + + b.ToTable("ScoreTypeExercise"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Semester", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Semester"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GithubId") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NeptunCode") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Student"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Subject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GitHubOrgName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NeptunCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.SubjectTeacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Role") + .HasColumnType("int"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.HasIndex("UserId"); + + b.ToTable("SubjectTeacher"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BmeEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GithubId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NeptunCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Assignment", b => + { + b.HasOne("GradeManagement.Data.Models.Exercise", "Exercise") + .WithMany("Assignments") + .HasForeignKey("ExerciseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.Student", "Student") + .WithMany("Assignments") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Exercise"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.AssignmentLog", b => + { + b.HasOne("GradeManagement.Data.Models.Assignment", "Assignment") + .WithMany("AssignmentLogs") + .HasForeignKey("AssignmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.PullRequest", "PullRequest") + .WithMany("AssignmentLogs") + .HasForeignKey("PullRequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Assignment"); + + b.Navigation("PullRequest"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Course", b => + { + b.HasOne("GradeManagement.Data.Models.Language", "Language") + .WithMany("Courses") + .HasForeignKey("LanguageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.Semester", "Semester") + .WithMany("Courses") + .HasForeignKey("SemesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.Subject", "Subject") + .WithMany("Courses") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Language"); + + b.Navigation("Semester"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Exercise", b => + { + b.HasOne("GradeManagement.Data.Models.Course", "Course") + .WithMany("Exercises") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Group", b => + { + b.HasOne("GradeManagement.Data.Models.Course", "Course") + .WithMany("Groups") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.GroupStudent", b => + { + b.HasOne("GradeManagement.Data.Models.Group", "Group") + .WithMany("GroupStudents") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.Student", "Student") + .WithMany("GroupStudents") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.GroupTeacher", b => + { + b.HasOne("GradeManagement.Data.Models.Group", "Group") + .WithMany("GroupTeachers") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.User", "User") + .WithMany("GroupTeachers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.PullRequest", b => + { + b.HasOne("GradeManagement.Data.Models.Assignment", "Assignment") + .WithMany("PullRequests") + .HasForeignKey("AssignmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.User", "Teacher") + .WithMany("PullRequests") + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Assignment"); + + b.Navigation("Teacher"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Score", b => + { + b.HasOne("GradeManagement.Data.Models.PullRequest", "PullRequest") + .WithMany("Scores") + .HasForeignKey("PullRequestId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.ScoreType", "ScoreType") + .WithMany("Scores") + .HasForeignKey("ScoreTypeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.User", "Teacher") + .WithMany("Scores") + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("PullRequest"); + + b.Navigation("ScoreType"); + + b.Navigation("Teacher"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.ScoreTypeExercise", b => + { + b.HasOne("GradeManagement.Data.Models.Exercise", "Exercise") + .WithMany("ScoreTypeExercises") + .HasForeignKey("ExerciseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.Score", null) + .WithMany("ScoreTypeExercises") + .HasForeignKey("ScoreId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("GradeManagement.Data.Models.ScoreType", "ScoreType") + .WithMany() + .HasForeignKey("ScoreTypeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Exercise"); + + b.Navigation("ScoreType"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.SubjectTeacher", b => + { + b.HasOne("GradeManagement.Data.Models.Subject", "Subject") + .WithMany("SubjectTeachers") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.User", "User") + .WithMany("SubjectTeachers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Subject"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Assignment", b => + { + b.Navigation("AssignmentLogs"); + + b.Navigation("PullRequests"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Course", b => + { + b.Navigation("Exercises"); + + b.Navigation("Groups"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Exercise", b => + { + b.Navigation("Assignments"); + + b.Navigation("ScoreTypeExercises"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Group", b => + { + b.Navigation("GroupStudents"); + + b.Navigation("GroupTeachers"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Language", b => + { + b.Navigation("Courses"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.PullRequest", b => + { + b.Navigation("AssignmentLogs"); + + b.Navigation("Scores"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Score", b => + { + b.Navigation("ScoreTypeExercises"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.ScoreType", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Semester", b => + { + b.Navigation("Courses"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Student", b => + { + b.Navigation("Assignments"); + + b.Navigation("GroupStudents"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.Subject", b => + { + b.Navigation("Courses"); + + b.Navigation("SubjectTeachers"); + }); + + modelBuilder.Entity("GradeManagement.Data.Models.User", b => + { + b.Navigation("GroupTeachers"); + + b.Navigation("PullRequests"); + + b.Navigation("Scores"); + + b.Navigation("SubjectTeachers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.cs b/grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.cs new file mode 100644 index 00000000..e69c2f9a --- /dev/null +++ b/grade-management-new/GradeManagement.Data/Migrations/20240926195542_mig11.cs @@ -0,0 +1,137 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GradeManagement.Data.Migrations +{ + /// + public partial class mig11 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Role", + table: "SubjectTeacher", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "SubjectId", + table: "Score", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "SubjectId", + table: "PullRequest", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "SubjectId", + table: "Group", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "SubjectId", + table: "Exercise", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "SubjectId", + table: "Assignment", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.CreateTable( + name: "ScoreTypeExercise", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ExerciseId = table.Column(type: "bigint", nullable: false), + ScoreTypeId = table.Column(type: "bigint", nullable: false), + Order = table.Column(type: "int", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + ScoreId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoreTypeExercise", x => x.Id); + table.ForeignKey( + name: "FK_ScoreTypeExercise_Exercise_ExerciseId", + column: x => x.ExerciseId, + principalTable: "Exercise", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ScoreTypeExercise_ScoreType_ScoreTypeId", + column: x => x.ScoreTypeId, + principalTable: "ScoreType", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ScoreTypeExercise_Score_ScoreId", + column: x => x.ScoreId, + principalTable: "Score", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_ScoreTypeExercise_ExerciseId", + table: "ScoreTypeExercise", + column: "ExerciseId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoreTypeExercise_ScoreId", + table: "ScoreTypeExercise", + column: "ScoreId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoreTypeExercise_ScoreTypeId", + table: "ScoreTypeExercise", + column: "ScoreTypeId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ScoreTypeExercise"); + + migrationBuilder.DropColumn( + name: "Role", + table: "SubjectTeacher"); + + migrationBuilder.DropColumn( + name: "SubjectId", + table: "Score"); + + migrationBuilder.DropColumn( + name: "SubjectId", + table: "PullRequest"); + + migrationBuilder.DropColumn( + name: "SubjectId", + table: "Group"); + + migrationBuilder.DropColumn( + name: "SubjectId", + table: "Exercise"); + + migrationBuilder.DropColumn( + name: "SubjectId", + table: "Assignment"); + } + } +} diff --git a/grade-management-new/GradeManagement.Data/Migrations/GradeManagementDbContextModelSnapshot.cs b/grade-management-new/GradeManagement.Data/Migrations/GradeManagementDbContextModelSnapshot.cs index ce3741a3..bc0f197a 100644 --- a/grade-management-new/GradeManagement.Data/Migrations/GradeManagementDbContextModelSnapshot.cs +++ b/grade-management-new/GradeManagement.Data/Migrations/GradeManagementDbContextModelSnapshot.cs @@ -47,6 +47,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StudentId") .HasColumnType("bigint"); + b.Property("SubjectId") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("ExerciseId"); @@ -153,6 +156,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("SubjectId") + .HasColumnType("bigint"); + b.Property("dueDate") .HasColumnType("datetimeoffset"); @@ -181,6 +187,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("SubjectId") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("CourseId"); @@ -284,6 +293,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Status") .HasColumnType("int"); + b.Property("SubjectId") + .HasColumnType("bigint"); + b.Property("TeacherId") .HasColumnType("bigint"); @@ -323,6 +335,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ScoreTypeId") .HasColumnType("bigint"); + b.Property("SubjectId") + .HasColumnType("bigint"); + b.Property("TeacherId") .HasColumnType("bigint"); @@ -360,6 +375,40 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("ScoreType"); }); + modelBuilder.Entity("GradeManagement.Data.Models.ScoreTypeExercise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExerciseId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("ScoreId") + .HasColumnType("bigint"); + + b.Property("ScoreTypeId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("ScoreId"); + + b.HasIndex("ScoreTypeId"); + + b.ToTable("ScoreTypeExercise"); + }); + modelBuilder.Entity("GradeManagement.Data.Models.Semester", b => { b.Property("Id") @@ -445,6 +494,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsDeleted") .HasColumnType("bit"); + b.Property("Role") + .HasColumnType("int"); + b.Property("SubjectId") .HasColumnType("bigint"); @@ -663,6 +715,30 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Teacher"); }); + modelBuilder.Entity("GradeManagement.Data.Models.ScoreTypeExercise", b => + { + b.HasOne("GradeManagement.Data.Models.Exercise", "Exercise") + .WithMany("ScoreTypeExercises") + .HasForeignKey("ExerciseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GradeManagement.Data.Models.Score", null) + .WithMany("ScoreTypeExercises") + .HasForeignKey("ScoreId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("GradeManagement.Data.Models.ScoreType", "ScoreType") + .WithMany() + .HasForeignKey("ScoreTypeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Exercise"); + + b.Navigation("ScoreType"); + }); + modelBuilder.Entity("GradeManagement.Data.Models.SubjectTeacher", b => { b.HasOne("GradeManagement.Data.Models.Subject", "Subject") @@ -699,6 +775,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("GradeManagement.Data.Models.Exercise", b => { b.Navigation("Assignments"); + + b.Navigation("ScoreTypeExercises"); }); modelBuilder.Entity("GradeManagement.Data.Models.Group", b => @@ -720,6 +798,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Scores"); }); + modelBuilder.Entity("GradeManagement.Data.Models.Score", b => + { + b.Navigation("ScoreTypeExercises"); + }); + modelBuilder.Entity("GradeManagement.Data.Models.ScoreType", b => { b.Navigation("Scores");