diff --git a/rag-2-backend/Controllers/AdministrationController.cs b/rag-2-backend/Controllers/AdministrationController.cs index 052febd..9535197 100644 --- a/rag-2-backend/Controllers/AdministrationController.cs +++ b/rag-2-backend/Controllers/AdministrationController.cs @@ -45,12 +45,11 @@ public UserResponse GetUserDetails([Required] int userId) return administrationService.GetUserDetails(UserUtil.GetPrincipalEmail(User), userId); } - /// Get students list by study year cycle (Admin, Teacher) + /// Get all users list (Admin, Teacher) [HttpGet("students")] [Authorize(Roles = "Admin, Teacher")] - public List GetStudents([FromQuery] [Required] int studyCycleYearA, - [FromQuery] [Required] int studyCycleYearB) + public List GetStudents() { - return administrationService.GetStudents(studyCycleYearA, studyCycleYearB); + return administrationService.GetStudents(); } } \ No newline at end of file diff --git a/rag-2-backend/Services/AdministrationService.cs b/rag-2-backend/Services/AdministrationService.cs index da0ad7b..cab0655 100644 --- a/rag-2-backend/Services/AdministrationService.cs +++ b/rag-2-backend/Services/AdministrationService.cs @@ -45,13 +45,9 @@ public UserResponse GetUserDetails(string principalEmail, int userId) return UserMapper.MapDetails(userUtil.GetUserByIdOrThrow(userId)); } - public List GetStudents(int studyCycleYearA, int studyCycleYearB) + public List GetStudents() { return context.Users - .Where(u => u.Role == Role.Student && - u.StudyCycleYearA == studyCycleYearA && - u.StudyCycleYearB == studyCycleYearB) - .OrderBy(u => u.Email) .Select(u => UserMapper.Map(u)) .ToList(); } diff --git a/rag-2-backend/Test/AdministrationServiceTest.cs b/rag-2-backend/Test/AdministrationServiceTest.cs index cd420b3..7ffd6ea 100644 --- a/rag-2-backend/Test/AdministrationServiceTest.cs +++ b/rag-2-backend/Test/AdministrationServiceTest.cs @@ -106,17 +106,17 @@ public void ShouldGetStudents() { var response = new UserResponse { - Id = 2, - Email = "email2@stud.prz.edu.pl", + Id = 1, + Email = "email@prz.edu.pl", Name = "John", - Role = Role.Student, + Role = Role.Admin, StudyCycleYearA = 2022, StudyCycleYearB = 2023 }; Assert.Equal( - JsonConvert.SerializeObject(new List { response }), - JsonConvert.SerializeObject(_administrationService.GetStudents(2022, 2023)) + JsonConvert.SerializeObject(response), + JsonConvert.SerializeObject(_administrationService.GetStudents()[0]) ); } } \ No newline at end of file