Example #1
0
        public async Task <ExtendedMovieDTO> AddMovie(ExtendedMovieDTO movie)
        {
            Movie newMovie = _mapper.Map <Movie>(movie);
            await _movieRepository.AddMovie(newMovie);

            return(movie);
        }
Example #2
0
 public async Task <ActionResult <ExtendedMovieDTO> > AddMovie(ExtendedMovieDTO movie)
 {
     try
     {
         return(new OkObjectResult(await _movieService.AddMovie(movie)));
     }
     catch
     {
         return(new StatusCodeResult(500));
     }
 }
        public async Task Add_Movie()
        {
            var movie = new ExtendedMovieDTO()
            {
                IMDBMovieId = "tt1798709",
                Name        = "Her",
                Runtime     = 126,
                ReleaseDate = new DateTime(2013, 1, 10),
                Synopsis    = "In a near future, a lonely writer develops an unlikely relationship with an operating system designed to meet his every need.",
                Rating      = 8.0
            };

            string json     = JsonConvert.SerializeObject(movie);
            var    response = await Client.PostAsync("/api/movies", new StringContent(json, Encoding.UTF8, "application/json"));

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var createdMovie = JsonConvert.DeserializeObject <ExtendedMovieDTO>(await response.Content.ReadAsStringAsync());

            Assert.NotNull(createdMovie);
        }