Beispiel #1
0
 public async Task <IActionResult> Add(Movie movie)
 {
     if (ModelState.IsValid)
     {
         await _movieService.AddAsync(movie);
     }
     return(RedirectToAction("Index", new{ cinemaId = movie.CinemaId }));
 }
Beispiel #2
0
        public async Task <IActionResult> Post([FromBody] MovieRequest movie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            await _movieService.AddAsync(movie);

            return(Ok());
        }
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price")]
                                                 MovieViewModel movie)
        {
            if (ModelState.IsValid)
            {
                await _movieService.AddAsync(Mapper.Map(movie)).ConfigureAwait(false);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(movie));
        }
Beispiel #4
0
 public async Task HandleAsync(CreateMovie command)
 {
     Console.WriteLine($"Creating movie {command.Title}");
     try
     {
         await movieService.AddAsync(command.Url, command.Title, command.Duration, command.Description);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     await busClient.PublishAsync(new MovieCreated(command.Id, command.Title));
 }
Beispiel #5
0
        public async Task <IActionResult> Create(Movie movie)
        {
            try
            {
                var viewmodel = await _movieService.AddAsync(movie);

                // TODO: Add insert logic here

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(movie));
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("MovieId,Title,Revenue,PosterUrl,VideoUrl,VideoPosterUrl,Summary,ReleaseDate,ContentRatingId")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                await movieService_.AddAsync(movie);

                return(RedirectToAction(nameof(Index)));
            }

            var contentRatings = await movieService_.GetContentRatingsAsync();

            ViewData["ContentRatingId"] = new SelectList(contentRatings, "ContentRatingId", "ShortDescription", movie.ContentRatingId);

            return(View(movie));
        }
        public async Task <IActionResult> Post([FromBody] Movie command)
        {
            try
            {
                if (command == null)
                {
                    return(NotFound());
                }

                var result = await _movieService.AddAsync(command);

                return(Ok(result));
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Request Error"));
            }
        }
        public async Task <ActionResult> Post([FromBody] AddMovieDto movie)
        {
            var id = await _movieService.AddAsync(movie);

            return(CreatedAtAction("Get", new { Id = id }));
        }
Beispiel #9
0
        public async Task <string> Create([FromBody] Movie movie)
        {
            await _service.AddAsync(movie);

            return("Movie created successfully");
        }