public async Task <IActionResult> GetTutorReleasedCourses(int tutorId, PaginationParameters paging) { try { if (paging.PageNumber <= 0) { return(BadRequest("page number must larger then 0")); } var tutor = await _tutorService.GetTutorByIdAsync(tutorId); if (tutor == null) { return(NotFound("tutor not found")); } var results = await _courseServices.GetPagedReleasedCoursesByTutorAsync(tutorId, paging.PageNumber, paging.PageSize); var paginationMetadata = GeneratePaginationMetadata(results.TotalCount, results.TotalPages, results.PageSize, results.CurrentPage); Response.Headers.Add("X-Pagination", paginationMetadata); Response.Headers.Add("Access-Control-Expose-Headers", "X-Pagination"); return(Ok(results.Items)); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { _logger.LogCritical($"GetTutorReleasedCourses() Error: {ex}"); return(StatusCode(500, "Internal Server Error")); } }