예제 #1
0
        public async Task <IActionResult> GetMoviesAsync([FromQuery] MovieQueryParameters movieQueryParameters)
        {
            Logger.LogInformation(nameof(GetMoviesAsync), "Web Request", HttpContext);

            if (movieQueryParameters == null)
            {
                throw new ArgumentNullException(nameof(movieQueryParameters));
            }

            List <Middleware.Validation.ValidationError> list = movieQueryParameters.Validate();

            if (list.Count > 0)
            {
                Logger.LogWarning(
                    new EventId((int)HttpStatusCode.BadRequest, HttpStatusCode.BadRequest.ToString()),
                    nameof(GetMoviesAsync),
                    "Invalid query string",
                    HttpContext);

                return(ResultHandler.CreateResult(list, Request.Path.ToString() + (Request.QueryString.HasValue ? Request.QueryString.Value : string.Empty)));
            }

            return(await DataService.Read <List <Movie> >(Request).ConfigureAwait(false));
        }