コード例 #1
0
        //[Authorize] if call by passing auth header, then sys will pick up the auth http.context
        public async Task <IActionResult> GetVideos(int?lectureId)
        {
            try
            {
                if (lectureId == null)
                {
                    return(BadRequest("must to indicate a lecture"));
                }
                var results = await _videoServices.GetVideByLectureAsync(lectureId.Value);

                return(Ok(results));
            }
            catch (CourseValidateException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (NotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (BadRequestException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (ForbiddenException)
            {
                return(Forbid());
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"GetVideos() Error: {ex}");
                return(StatusCode(500, "Internal Server Error"));
            }
        }