public async Task <IActionResult> GetActorsAsync([FromQuery] ActorQueryParameters actorQueryParameters)
        {
            _ = actorQueryParameters ?? throw new ArgumentNullException(nameof(actorQueryParameters));

            return(await ResultHandler.Handle(
                       dal.GetActorsAsync(actorQueryParameters), actorQueryParameters.GetMethodText(HttpContext), Constants.ActorsControllerException, logger)
                   .ConfigureAwait(false));
        }
        public async Task <IActionResult> GetMovieByIdAsync([FromRoute] MovieIdParameter movieIdParameter)
        {
            _ = movieIdParameter ?? throw new ArgumentNullException(nameof(movieIdParameter));

            string method = nameof(GetMovieByIdAsync) + movieIdParameter.MovieId;

            return(await ResultHandler.Handle(
                       dal.GetMovieAsync(movieIdParameter.MovieId), method, "Movie Not Found", logger)
                   .ConfigureAwait(false));
        }
        public async Task <IActionResult> GetActorByIdAsync([FromRoute] ActorIdParameter actorIdParameter)
        {
            _ = actorIdParameter ?? throw new ArgumentNullException(nameof(actorIdParameter));

            string method = nameof(GetActorByIdAsync) + actorIdParameter.ActorId;

            // return result
            return(await ResultHandler.Handle(
                       dal.GetActorAsync(actorIdParameter.ActorId), method, "Actor Not Found", logger)
                   .ConfigureAwait(false));
        }
Beispiel #4
0
        public async Task <IActionResult> GetActorByIdAsync(string actorId)
        {
            string method = "GetActorByIdAsync " + actorId;

            // validate actorId
            var result = ParameterValidator.ActorId(actorId, method, logger);

            if (result != null)
            {
                return(result);
            }

            // return result
            return(await ResultHandler.Handle(dal.GetActorAsync(actorId), method, "Actor Not Found", logger).ConfigureAwait(false));
        }
Beispiel #5
0
        public async System.Threading.Tasks.Task <IActionResult> GetMovieByIdAsync(string movieId)
        {
            string method = "GetMovieByIdAsync " + movieId;

            // validate movieId
            ContentResult result = ParameterValidator.MovieId(movieId, method, logger);

            if (result != null)
            {
                return(result);
            }

            // get movie by movieId
            return(await ResultHandler.Handle(dal.GetMovieAsync(movieId), method, "Movie Not Found", logger).ConfigureAwait(false));
        }
Beispiel #6
0
        public async Task <IActionResult> GetActorsAsync([FromQuery] string q, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = Constants.DefaultPageSize)
        {
            string method = GetMethodText(q, pageNumber, pageSize);

            // validate query string parameters
            var result = ParameterValidator.Common(HttpContext?.Request?.Query, q, pageNumber, pageSize, method, logger);

            if (result != null)
            {
                return(result);
            }

            // convert to zero based index
            pageNumber = pageNumber > 1 ? pageNumber - 1 : 0;

            return(await ResultHandler.Handle(dal.GetActorsAsync(q, pageNumber *pageSize, pageSize), method, Constants.ActorsControllerException, logger).ConfigureAwait(false));
        }
Beispiel #7
0
        public async Task <IActionResult> GetMoviesAsync([FromQuery] string q = null, [FromQuery] string genre = null, [FromQuery] int year = 0, [FromQuery] double rating = 0, [FromQuery] string actorId = null, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = Constants.DefaultPageSize)
        {
            string method = GetMethodText(q, genre, year, rating, actorId, pageNumber, pageSize);

            // validate query string parameters
            ContentResult result = ParameterValidator.Movies(HttpContext?.Request?.Query, q, genre, year, rating, actorId, pageNumber, pageSize, method, logger);

            if (result != null)
            {
                return(result);
            }

            // convert to zero based page index
            pageNumber = pageNumber > 1 ? pageNumber - 1 : 0;

            return(await ResultHandler.Handle(dal.GetMoviesAsync(q, genre, year, rating, actorId, pageNumber *pageSize, pageSize), method, Constants.MoviesControllerException, logger).ConfigureAwait(false));
        }
Beispiel #8
0
        public async Task <IActionResult> GetFeaturedMovieAsync()
        {
            string method = nameof(GetFeaturedMovieAsync);

            logger.LogInformation(method);

            List <string> featuredMovies = await dal.GetFeaturedMovieListAsync().ConfigureAwait(false);

            if (featuredMovies != null && featuredMovies.Count > 0)
            {
                // get random featured movie by movieId
                string movieId = featuredMovies[rand.Next(0, featuredMovies.Count - 1)];

                // get movie by movieId
                return(await ResultHandler.Handle(dal.GetMovieAsync(movieId), method, Constants.FeaturedControllerException, logger).ConfigureAwait(false));
            }

            return(NotFound());
        }
 public async Task <IActionResult> GetGenresAsync()
 {
     // get list of genres as list of string
     return(await ResultHandler.Handle(keyRotation.RetryCosmosPolicy.ExecuteAsync(() => dal.GetGenresAsync()), nameof(GetGenresAsync), Constants.GenresControllerException, logger).ConfigureAwait(false));
 }
 public async Task <IActionResult> GetGenresAsync()
 {
     // get list of genres as list of string
     return(await ResultHandler.Handle(dal.GetGenresAsync(), nameof(GetGenresAsync), Constants.GenresControllerException, logger).ConfigureAwait(false));
 }