From 4439691fb92a6d8e510cf2ee135ba65f83582135 Mon Sep 17 00:00:00 2001 From: Lucca Santangelo <luccasant95@gmail.com> Date: Sun, 13 Dec 2020 11:21:36 -0300 Subject: [PATCH] asd --- .../Tsi1.Api/Controllers/CourseController.cs | 4 ++-- .../Interfaces/IStudentCourseResultService.cs | 2 +- .../Services/StudentCourseResultService.cs | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs b/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs index e717886..16a4791 100644 --- a/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs +++ b/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs @@ -305,7 +305,7 @@ namespace Tsi1.Api.Controllers return Ok(result.Data); } - [Authorize(Roles = UserTypes.Professor)] + [Authorize(Roles = UserTypes.FacultyAdmin)] [HttpPost("CloseRecord/{courseId}")] public async Task<IActionResult> CloseRecord(int courseId) { @@ -317,7 +317,7 @@ namespace Tsi1.Api.Controllers return BadRequest(courseResult.Message); } - var studentCourseResult = await _studentCourseResultService.GetLastStudentCourseResults(courseId, userId); + var studentCourseResult = await _studentCourseResultService.GetLastStudentCourseResults(courseId, userId, false); if (studentCourseResult.HasError) { return BadRequest(studentCourseResult.Message); diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs index c590fff..1cd93ee 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs @@ -17,7 +17,7 @@ namespace Tsi1.BusinessLayer.Interfaces Task<ServiceResult<StudentCourseResultPreviewDto>> GetMyLastResult(int courseId, int userId); - Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId); + Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId, bool isProfessor = true); Task<ServiceResult<List<StudentCourseResultQuantityDto>>> GetAllLastStudentCourseResults(int tenantId); } } diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs index 9eb5e0c..2b3b914 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs @@ -99,17 +99,20 @@ namespace Tsi1.BusinessLayer.Services return result; } - public async Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId) + public async Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId, bool isProfessor = true) { var result = new ServiceResult<List<StudentCourseResultPreviewDto>>(); - var professorValidation = await this.ProfessorValidations(courseId, userId); - - if (professorValidation.HasError) + if (isProfessor) { - result.HasError = true; - result.AddMessage(professorValidation.Message); - return result; + var professorValidation = await this.ProfessorValidations(courseId, userId); + + if (professorValidation.HasError) + { + result.HasError = true; + result.AddMessage(professorValidation.Message); + return result; + } } var studentIds = await _context.StudentCourses -- GitLab