Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Grades Assigning #62

Merged
merged 33 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
feaeb33
Redesign a model for assigned grade
romandykyi Dec 9, 2023
5a00305
Add ActivityType entity and its DTOs
romandykyi Dec 10, 2023
acf7dd3
Implement `ActivityType` service
romandykyi Dec 10, 2023
2bd6970
Implement activity types endpoints
romandykyi Dec 10, 2023
52006a9
Configure test data for `ActivityType`
romandykyi Dec 10, 2023
4de55e6
Update README.md
romandykyi Dec 10, 2023
85631fc
Add DTOs for assigned grades
romandykyi Dec 11, 2023
0a0d339
Make the assigned grades validator class generic
romandykyi Dec 11, 2023
0cb4264
Add DTOs for ClassGrade and validation
romandykyi Dec 11, 2023
53c7e87
Fix error in a test
romandykyi Dec 11, 2023
ae909d2
Create `IAssignedGradesService` interface
romandykyi Dec 11, 2023
8af09cc
Manage namespaces
romandykyi Dec 12, 2023
05c6679
Merge branch 'master' into implement-grades-assigning
romandykyi Dec 25, 2023
b97b853
Merge `ClassGrade` and `AssignedGrade`
romandykyi Dec 25, 2023
5a2d47f
Add `AssignedGrades` table
romandykyi Dec 25, 2023
346663e
Add `AssignedGradeUpdateDto`
romandykyi Dec 25, 2023
23c8080
Implement `AssignedGradesService`
romandykyi Dec 25, 2023
7a71fc2
Implement `AssignedGradesFilter`
romandykyi Dec 25, 2023
f0d17ed
Refactor authorization handlers
romandykyi Dec 26, 2023
a9477f5
Update comments
romandykyi Dec 26, 2023
2188767
Refactor `AssignedGradesFilter`
romandykyi Dec 26, 2023
fa0336b
Add an additional method for `GroupsService`
romandykyi Dec 26, 2023
b876a6b
Remove unnecessary code
romandykyi Dec 26, 2023
64c3add
Add `Async` suffix
romandykyi Dec 26, 2023
97afc7a
Forbid students view another students via groups or semesters
romandykyi Dec 26, 2023
c7c79e1
Implement some assigned grades get methods
romandykyi Dec 26, 2023
bde1ca9
Implement `IAssignedGradesService.GetAssignerIdAsync`
romandykyi Dec 26, 2023
5c31126
Remove redundant includes
romandykyi Dec 26, 2023
2ed6766
Update return type
romandykyi Dec 26, 2023
3b230b2
Fix dto property name
romandykyi Dec 26, 2023
c5f211a
Implement controller for assigned grades
romandykyi Dec 26, 2023
beeeda5
Fix false negatives in tests
romandykyi Dec 26, 2023
8f1e0f9
Fix accidental change
romandykyi Dec 26, 2023
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
Prev Previous commit
Next Next commit
Implement IAssignedGradesService.GetAssignerIdAsync
  • Loading branch information
romandykyi committed Dec 26, 2023
commit bde1ca9197997982ae665cc3bf5620c07aa96447
17 changes: 17 additions & 0 deletions Core/Services/University/Grades/IAssignedGradesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

namespace EUniversity.Core.Services.University.Grades;

/// <summary>
/// Response of the <see cref="IGroupsService.GetAssignerIdAsync(int)" /> method.
/// </summary>
/// <param name="GradeExists">Flag that determines whether requested assigned grade exists.</param>
/// <param name="AssignerId">ID of the assigner of the grade.</param>
public record GetAssignerIdResponse(bool GradeExists, string? AssignerId);

/// <summary>
/// An interface for retrieving and assigning grades.
/// </summary>
Expand Down Expand Up @@ -66,4 +73,14 @@ Task<Page<TViewDto>> GetPageAsync<TViewDto>(PaginationProperties properties, IFi
/// it returns <see langword="false" />.
/// </returns>
Task<bool> DeleteAsync(int id);

/// <summary>
/// Gets an ID of the assigner of the assigned grade.
/// </summary>
/// <param name="id">ID of the assigned grade.</param>
/// <returns>
/// A task that represent the asynchronous operation and the result
/// of the operation.
/// </returns>
Task<GetAssignerIdResponse> GetAssignerIdAsync(int id);
}
14 changes: 14 additions & 0 deletions Infrastructure/Services/University/Grades/AssignedGradesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,18 @@ public async Task<bool> DeleteAsync(int id)

return true;
}

/// <inheritdoc />
public async Task<GetAssignerIdResponse> GetAssignerIdAsync(int id)
{
var grade = await _dbContext.AssignedGrades
.AsNoTracking()
.Where(g => g.Id == id)
.FirstOrDefaultAsync();
if (grade == null)
{
return new(false, null);
}
return new(true, grade.AssignerId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,35 @@ public async Task Delete_ElementDoesNotExist_ReturnsFalse()
// Assert
Assert.That(result, Is.False);
}

[Test]
public async Task GetAssignerId_GradeExists_ReturnsGroupOwner()
{
// Arrange
var grade = await CreateTestAssignedGradeAsync();

// Act
var result = await _service.GetAssignerIdAsync(grade.Id);

// Assert
Assert.Multiple(() =>
{
Assert.That(result.GradeExists, Is.True);
Assert.That(result.AssignerId, Is.EqualTo(grade.AssignerId));
});
}

[Test]
public async Task GetAssignerId_GradeDoesNotExist_ReturnsCorrectResponse()
{
// Act
var result = await _service.GetAssignerIdAsync(-1);

// Assert
Assert.Multiple(() =>
{
Assert.That(result.GradeExists, Is.False);
Assert.That(result.AssignerId, Is.Null);
});
}
}