Skip to content

Commit

Permalink
Run Visual Studio code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
romandykyi committed Dec 27, 2023
1 parent 762d599 commit 208c3f7
Show file tree
Hide file tree
Showing 26 changed files with 248 additions and 272 deletions.
2 changes: 1 addition & 1 deletion Core/Dtos/University/Grades/AssignedGradeViewDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EUniversity.Core.Dtos.University.Grades;

public record AssignedGradeViewDto(int Id, string? Notes,
public record AssignedGradeViewDto(int Id, string? Notes,
GradeMinimalViewDto Grade, GroupMinimalViewDto? Group,
UserViewDto? Assigner, UserViewDto? Reassigner,
StudentPreviewDto? Student,
Expand Down
2 changes: 1 addition & 1 deletion Core/Dtos/Users/EditUserDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
namespace EUniversity.Core.Dtos.Users;

[ValidateNever] // Remove data annotations validation
public record EditUserDto(string UserName,
public record EditUserDto(string UserName,
string Email, string FirstName, string LastName, string? MiddleName = null) :
RegisterDto(Email, FirstName, LastName, MiddleName);
2 changes: 1 addition & 1 deletion Core/Services/Users/IUsersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Task<Page<UserPreviewDto>> GetUsersInRoleAsync(string role, PaginationProperties
/// <returns>
/// Page with all users.
/// </returns>
Task<Page<UserPreviewDto>> GetAllUsersAsync(PaginationProperties? properties = null,
Task<Page<UserPreviewDto>> GetAllUsersAsync(PaginationProperties? properties = null,
IFilter<ApplicationUser>? filter = null, bool onlyDeleted = false);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task SkipRoleAccessesNotOwnData_Succeeds(string role)
{
// Arrange
ClaimsPrincipal user = GetUser(TestUserId, role);
AuthorizationHandlerContext context = GetHandlerContext(user, Roles.Administrator, Roles.Teacher);
AuthorizationHandlerContext context = GetHandlerContext(user, Roles.Administrator, Roles.Teacher);
AccessOnlyOwnDataAuthorizationHandler handler = new();

// Act
Expand All @@ -71,7 +71,7 @@ public async Task UserAccessesOwnData_Succeeds()
{
// Arrange
ClaimsPrincipal user = GetUser(TestRouteStudentId);
AuthorizationHandlerContext context = GetHandlerContext(user);
AuthorizationHandlerContext context = GetHandlerContext(user);
AccessOnlyOwnDataAuthorizationHandler handler = new();

// Act
Expand All @@ -86,7 +86,7 @@ public async Task UserAccessesDataOfAnotherUser_Fails()
{
// Arrange
ClaimsPrincipal user = GetUser(TestUserId);
AuthorizationHandlerContext context = GetHandlerContext(user);
AuthorizationHandlerContext context = GetHandlerContext(user);
AccessOnlyOwnDataAuthorizationHandler handler = new();

// Act
Expand Down
59 changes: 29 additions & 30 deletions EUniversity.Tests/Filters/AssignedGradesFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using EUniversity.Core.Models.University;
using EUniversity.Core.Models.University.Grades;
using EUniversity.Infrastructure.Filters;
using System.ComponentModel;

namespace EUniversity.Tests.Filters;

Expand Down Expand Up @@ -52,56 +51,56 @@ public class AssignedGradesFilterTests

private static readonly AssignedGrade[] TestData =
{
new()
new()
{
Id = 500,
Grade = TestGrade1, GradeId = TestGrade1.Id,
AssignerId = TestTeacher1.Id, ReassignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
Id = 500,
Grade = TestGrade1, GradeId = TestGrade1.Id,
AssignerId = TestTeacher1.Id, ReassignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
GroupId = TestGroup2.Id,
ActivityTypeId = TestActivityType.Id
},
new()
new()
{
Id = 501,
Grade = TestGrade1, GradeId = TestGrade1.Id,
AssignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
Id = 501,
Grade = TestGrade1, GradeId = TestGrade1.Id,
AssignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
GroupId = TestGroup1.Id,
ActivityTypeId = TestActivityType.Id
},
new()
new()
{
Id = 502,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher1.Id, ReassignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
Id = 502,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher1.Id, ReassignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
GroupId = TestGroup1.Id
},
new()
new()
{
Id = 503,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
Id = 503,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher2.Id,
StudentId = TestStudent1.Id,
GroupId = TestGroup2.Id,
ActivityTypeId = TestActivityType.Id
},
new()
new()
{
Id = 504,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher1.Id, ReassignerId = TestTeacher2.Id,
StudentId = TestStudent2.Id,
Id = 504,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher1.Id, ReassignerId = TestTeacher2.Id,
StudentId = TestStudent2.Id,
GroupId = TestGroup1.Id,
ActivityTypeId = TestActivityType.Id
},
new()
new()
{
Id = 505,
Grade = TestGrade2, GradeId = TestGrade2.Id,
Id = 505,
Grade = TestGrade2, GradeId = TestGrade2.Id,
AssignerId = TestTeacher2.Id, ReassignerId = TestTeacher1.Id,
StudentId = TestStudent1.Id,
StudentId = TestStudent1.Id,
GroupId = TestGroup1.Id
},
};
Expand Down
5 changes: 0 additions & 5 deletions EUniversity.Tests/Filters/SemestersFilterTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using EUniversity.Core.Models.University;
using EUniversity.Infrastructure.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EUniversity.Tests.Filters;

Expand Down
1 change: 0 additions & 1 deletion EUniversity/Auth/AccessOnlyOwnDataAuthorizationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Duende.IdentityServer.Extensions;
using EUniversity.Controllers;
using EUniversity.Core.Policy;
using IdentityModel;
using Microsoft.AspNetCore.Authorization;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public AccessOnlyOwnDataAuthorizationRequirement() : this(Enumerable.Empty<strin

}

public AccessOnlyOwnDataAuthorizationRequirement(params string[] skipRoles) :
public AccessOnlyOwnDataAuthorizationRequirement(params string[] skipRoles) :
this(skipRoles.AsEnumerable())
{

Expand Down
1 change: 0 additions & 1 deletion EUniversity/Controllers/University/CoursesController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EUniversity.Core.Dtos.University;
using EUniversity.Core.Models.University;
using EUniversity.Core.Pagination;
using EUniversity.Core.Policy;
using EUniversity.Core.Services.University;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EUniversity.Core.Dtos.University.Grades;
using EUniversity.Core.Models.University.Grades;
using EUniversity.Core.Pagination;
using EUniversity.Core.Policy;
using EUniversity.Infrastructure.Filters;
Expand Down
2 changes: 1 addition & 1 deletion EUniversity/Controllers/University/GroupsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public async Task<IActionResult> GetGradesInGroupAsync(
HttpContext));
}
// Forbid if user is not an administrator and doesn't own the group
if (response.OwnerId != callerId &&
if (response.OwnerId != callerId &&
!User.HasClaim(JwtClaimTypes.Role, Roles.Administrator))
{
return Forbid();
Expand Down
2 changes: 1 addition & 1 deletion EUniversity/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class UsersController : ControllerBase

public const string StudentIdRouteKey = "studentId";

public UsersController(IAuthService authService,
public UsersController(IAuthService authService,
IUsersService usersService, IAssignedGradesService assignedGradesService)
{
_authService = authService;
Expand Down
2 changes: 1 addition & 1 deletion Infrastructure/Filters/ClassesFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public IQueryable<Class> Apply(IQueryable<Class> query)
}
if (Properties.StudentId != null)
{
query = query.Where(c =>
query = query.Where(c =>
c.Group!.Students.Select(s => s.Id).Contains(Properties.StudentId));
}
if (Properties.TeacherId != null)
Expand Down
4 changes: 1 addition & 3 deletions Infrastructure/Filters/GradesFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Bogus.DataSets;
using EUniversity.Core.Filters;
using EUniversity.Core.Models;
using EUniversity.Core.Filters;
using EUniversity.Core.Models.University.Grades;

namespace EUniversity.Infrastructure.Filters;
Expand Down
4 changes: 2 additions & 2 deletions Infrastructure/Filters/GroupsFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class GroupsFilter : DefaultFilter<Group>
/// </summary>
public GroupsFilterProperties Properties { get; }

public GroupsFilter(GroupsFilterProperties properties,
string name, DefaultFilterSortingMode sortingMode = DefaultFilterSortingMode.Default) :
public GroupsFilter(GroupsFilterProperties properties,
string name, DefaultFilterSortingMode sortingMode = DefaultFilterSortingMode.Default) :
base(name, sortingMode)
{
Properties = properties;
Expand Down
2 changes: 1 addition & 1 deletion Infrastructure/Filters/SemestersFilterProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
/// </summary>
/// <param name="MaxDateFrom">Minimum start date of the semester to filter by.</param>
/// <param name="MinDateTo">Maximum start date of the semester to filter by.</param>
public record SemestersFilterProperties(DateTimeOffset? MaxDateFrom = null,
public record SemestersFilterProperties(DateTimeOffset? MaxDateFrom = null,
DateTimeOffset? MinDateTo = null);
134 changes: 66 additions & 68 deletions Infrastructure/Migrations/20231209173343_RemoveOldAssignedGrades.cs
Original file line number Diff line number Diff line change
@@ -1,81 +1,79 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace EUniversity.Infrastructure.Migrations
namespace EUniversity.Infrastructure.Migrations;

/// <inheritdoc />
public partial class RemoveOldAssignedGrades : Migration
{
/// <inheritdoc />
public partial class RemoveOldAssignedGrades : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CourseGrades");
}
migrationBuilder.DropTable(
name: "CourseGrades");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CourseGrades",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CourseId = table.Column<int>(type: "int", nullable: false),
GradeId = table.Column<int>(type: "int", nullable: false),
StudentId = table.Column<string>(type: "nvarchar(450)", nullable: true),
TeacherId = table.Column<string>(type: "nvarchar(450)", nullable: true),
Date = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CourseGrades", x => x.Id);
table.ForeignKey(
name: "FK_CourseGrades_AspNetUsers_StudentId",
column: x => x.StudentId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_CourseGrades_AspNetUsers_TeacherId",
column: x => x.TeacherId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_CourseGrades_Courses_CourseId",
column: x => x.CourseId,
principalTable: "Courses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CourseGrades_Grades_GradeId",
column: x => x.GradeId,
principalTable: "Grades",
principalColumn: "Id");
});
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CourseGrades",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CourseId = table.Column<int>(type: "int", nullable: false),
GradeId = table.Column<int>(type: "int", nullable: false),
StudentId = table.Column<string>(type: "nvarchar(450)", nullable: true),
TeacherId = table.Column<string>(type: "nvarchar(450)", nullable: true),
Date = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CourseGrades", x => x.Id);
table.ForeignKey(
name: "FK_CourseGrades_AspNetUsers_StudentId",
column: x => x.StudentId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_CourseGrades_AspNetUsers_TeacherId",
column: x => x.TeacherId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_CourseGrades_Courses_CourseId",
column: x => x.CourseId,
principalTable: "Courses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CourseGrades_Grades_GradeId",
column: x => x.GradeId,
principalTable: "Grades",
principalColumn: "Id");
});

migrationBuilder.CreateIndex(
name: "IX_CourseGrades_CourseId",
table: "CourseGrades",
column: "CourseId");
migrationBuilder.CreateIndex(
name: "IX_CourseGrades_CourseId",
table: "CourseGrades",
column: "CourseId");

migrationBuilder.CreateIndex(
name: "IX_CourseGrades_GradeId",
table: "CourseGrades",
column: "GradeId");
migrationBuilder.CreateIndex(
name: "IX_CourseGrades_GradeId",
table: "CourseGrades",
column: "GradeId");

migrationBuilder.CreateIndex(
name: "IX_CourseGrades_StudentId",
table: "CourseGrades",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_CourseGrades_StudentId",
table: "CourseGrades",
column: "StudentId");

migrationBuilder.CreateIndex(
name: "IX_CourseGrades_TeacherId",
table: "CourseGrades",
column: "TeacherId");
}
migrationBuilder.CreateIndex(
name: "IX_CourseGrades_TeacherId",
table: "CourseGrades",
column: "TeacherId");
}
}
Loading

0 comments on commit 208c3f7

Please sign in to comment.