public ActionResult DeleteMovie(int movieId)
        {
            try
            {
                var resultData = movieServices.DeleteMovie(movieId);

                return(Ok(ServicesExtension.SuccessfulResult(resultData)));
            }
            catch (Exception exp)
            {
                return(new JsonResult(ServicesExtension.ErrorResult(exp)));
            }
        }
        public ActionResult CreateMovie([FromBody] MovieDto movie)
        {
            try
            {
                var resultData = movieServices.CreateMovie(movie);

                return(Ok(ServicesExtension.SuccessfulResult(resultData)));
            }
            catch (Exception exp)
            {
                return(new JsonResult(ServicesExtension.ErrorResult(exp)));
            }
        }
        public ActionResult GetMoviesStats()
        {
            try
            {
                var resultData = movieServices.GetMovieStats();

                return(Ok(ServicesExtension.SuccessfulResult(resultData)));
            }
            catch (Exception exp)
            {
                return(new JsonResult(ServicesExtension.ErrorResult(exp)));
            }
        }
        public ActionResult GetMovie(int movieId)
        {
            try
            {
                var resultData = movieServices.GetMovie(movieId);

                if (resultData == null)
                {
                    return(NotFound());
                }

                return(Ok(ServicesExtension.SuccessfulResult(resultData)));
            }
            catch (Exception exp)
            {
                return(new JsonResult(ServicesExtension.ErrorResult(exp)));
            }
        }
Beispiel #5
0
        public void GetMovies_ShouldReturn_MoviesList_DataTypeOfMovieDataView()
        {
            //Arrange
            var fixture         = new Fixture();
            var movieMockData   = fixture.Create <List <MovieDataView> >().AsQueryable();
            var movieResultData = ServicesExtension.SuccessfulResult(movieMockData);

            mockMovieService.Setup(m => m.GetMovies()).Returns(movieMockData);


            //Act
            var actualDataResult          = sut.GetMovies() as OkObjectResult;
            var extractedActualResultData = ((ResultDto)actualDataResult.Value).Data;

            //Assert
            Assert.Equal(movieMockData, extractedActualResultData);
            var items = Assert.IsAssignableFrom <IQueryable <MovieDataView> >(extractedActualResultData);
        }