Skip to content

Commit

Permalink
Return empty students courses list (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeseggie committed Jun 23, 2023
1 parent 4b6e803 commit 895857d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<IActionResult> GetStudentCourseByIdAsync(Guid id)
var result = await studentCourseService.GetStudentCourseByIdAsync(id);
if (!result.IsSuccess)
{
return NotFound(result.ErrorMessage);
return BadRequest(result.ErrorMessage);
}

var newStudentCourse = result.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ public async Task<Result<IEnumerable<StudentCourse>>> GetStudentCoursesAsync(Gui
.Include(studentCourse => studentCourse.Scholarship)
.ThenInclude(scholarship => scholarship!.Country)
.AsQueryable();

if (!studentCoursesQuery.Any())
{
return Result<IEnumerable<StudentCourse>>.Failure("No student courses found.");
}

if (studentId is not null)
if (studentCoursesQuery.Any() && studentId is not null)
{
studentCoursesQuery = studentCoursesQuery.Where(studentCourse => studentCourse.StudentId == studentId);
}
Expand Down

0 comments on commit 895857d

Please sign in to comment.