diff --git a/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs b/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs index 90c4e0573f50bae1a7edc46cf7eec814ee952a53..e053ee6701ef25180439b17232fdd4d7c7e1c30c 100644 --- a/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs +++ b/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs @@ -110,7 +110,10 @@ namespace Tsi1.Api.Controllers [HttpPost("AddProfessorToCourse")] public async Task<IActionResult> AddProfessorToCourse(ProfessorCourseDto professorCourseDto) { - var result = await _courseService.AddProfessorToCourse(professorCourseDto); + var userId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Id").Value); + var userType = HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role).Value; + + var result = await _courseService.AddProfessorToCourse(professorCourseDto, userId, userType); if (result.HasError) { diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/ICourseService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/ICourseService.cs index 9bd530cae25bdebd3116e32ad7084eb6bd2d369e..846f11c2a36b56d22cb06a342fc16dcb69a00295 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/ICourseService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/ICourseService.cs @@ -14,7 +14,7 @@ namespace Tsi1.BusinessLayer.Interfaces Task<ServiceResult<bool>> Matriculate(int userId, int courseId); - Task<ServiceResult<bool>> AddProfessorToCourse(ProfessorCourseDto professorCourseDto); + Task<ServiceResult<bool>> AddProfessorToCourse(ProfessorCourseDto professorCourseDto, int userId, string userType); Task<ServiceResult<List<CoursePreviewDto>>> GetAll(int tenantId, bool isTemplate = false); diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Services/CourseService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Services/CourseService.cs index b06b5c4c1c32236035ed1ac5f87fb5ed73fa6b03..f7f639b135c582f253af1754e61b63d1e1dd01f9 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Services/CourseService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Services/CourseService.cs @@ -160,7 +160,7 @@ namespace Tsi1.BusinessLayer.Services if (user == null || user.Professor == null) { result.HasError = true; - result.Message = string.Format(ErrorMessages.UserDoesNotExist, user.Username); + result.Message = string.Format(ErrorMessages.UserDoesNotExist, user.Id); return result; }