Ejemplo n.º 1
0
        public async Task <IActionResult> GetActorsAsync([FromQuery] ActorQueryParameters actorQueryParameters)
        {
            Logger.LogInformation(nameof(GetActorsAsync), "Web Request", HttpContext);

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

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

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

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

            return(await DataService.Read <List <Actor> >(Request).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a CancellationTokenSource that cancels on ctl-c pressed
        /// </summary>
        /// <returns>CancellationTokenSource</returns>
        private static CancellationTokenSource SetupCtlCHandler()
        {
            CancellationTokenSource ctCancel = new CancellationTokenSource();

            Console.CancelKeyPress += async(sender, e) =>
            {
                e.Cancel = true;
                ctCancel.Cancel();

                Logger.LogInformation("CtlCHandler", "Ctl-C Pressed");

                // trigger graceful shutdown for the webhost
                // force shutdown after timeout, defined in UseShutdownTimeout within BuildHost() method
                await host.StopAsync().ConfigureAwait(false);

                // end the app
                Environment.Exit(0);
            };

            return(ctCancel);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetGenresAsync()
        {
            Logger.LogInformation(nameof(GetGenresAsync), "Web Request", HttpContext);

            return(await DataService.Read <List <string> >(Request).ConfigureAwait(false));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetFeaturedMovieAsync()
        {
            Logger.LogInformation(nameof(GetFeaturedMovieAsync), "Web Request", HttpContext);

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