Ejemplo n.º 1
0
        public async Task <ActionResult> AddScreening(
            [FromRoute] Guid movieId,
            [FromForm] AddScreeningViewModel model,
            [FromServices] ISendAddScreeningCommandService service,
            [FromServices] IResourceAwaiter awaiter)
        {
            AddNewScreening command = model.CreateCommand();

            IResult <ScreeningLocation> result = await
                                                 service.SendAddScreeningCommand(command);

            switch (result)
            {
            case Success <ScreeningLocation> success:
                await awaiter.AwaitResource(success.Value.Uri);

                var routeValues = new { movieId };
                return(RedirectToAction("Screenings", routeValues));

            case Error <ScreeningLocation> error:
                ModelState.AddModelError(string.Empty, error.Message);
                break;
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create(
            [FromForm] CreateMovieViewModel model,
            [FromServices] ISendCreateMovieCommandService service,
            [FromServices] IResourceAwaiter awaiter)
        {
            CreateNewMovie command = model.CreateCommand();

            IResult <MovieLocation> result = await
                                             service.SendCreateMovieCommand(command);

            switch (result)
            {
            case Success <MovieLocation> success:
                await awaiter.AwaitResource(success.Value.Uri);

                return(RedirectToAction(nameof(Index)));

            case Error <MovieLocation> error:
                ModelState.AddModelError(string.Empty, error.Message);
                break;
            }

            return(View(model));
        }