public void UpdateTest()
        {
            //Arrange
            var seedDB = new List <MovieModelDAL>();
            var seed   = new MovieModelDAL
            {
                ID         = 5050,
                Title      = "Movie",
                Year       = 2018,
                Rated      = "10",
                Runtime    = "20 min",
                Genre      = "Commedy",
                Director   = "Director",
                Plot       = "Some Plot",
                Poster     = "www.poster.com",
                ImdbRating = 10f,
                ScreenShot = "www.screenshot.com"
            };

            seedDB.Add(seed);
            var controller = new MoviesLogic(new MovieDALStub(seedDB));
            var rightInput = new MovieModelBLL
            {
                ID         = 5050,
                Title      = "Movie",
                Year       = 2018,
                Rated      = "10",
                Runtime    = "20 min",
                Genre      = "Commedy",
                Director   = "Director",
                Plot       = "Some Plot",
                Poster     = "www.poster.com",
                ImdbRating = 10f,
                ScreenShot = "www.screenshot.com"
            };
            var wrongInput = new MovieModelBLL
            {
                ID         = -1,
                Title      = "",
                Year       = -2018,
                Rated      = null,
                Runtime    = null,
                Genre      = null,
                Director   = null,
                Plot       = null,
                Poster     = null,
                ImdbRating = -100f,
                ScreenShot = null
            };

            //Act
            var result1 = controller.Update(rightInput);
            var result2 = controller.Update(wrongInput);

            //Assert
            Assert.IsTrue(result1 && !result2);
        }
Example #2
0
        public ActionResult PutMovie(MovieViewModel movieViewModel)
        {
            if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false))
            {
                return(RedirectToRoute(new
                {
                    controller = "Home",
                    action = "Index"
                }));
            }

            var movieModelBLL = new MovieModelBLL()
            {
                ID         = movieViewModel.Id,
                Title      = movieViewModel.Title,
                Year       = movieViewModel.Year,
                Rated      = movieViewModel.Rated,
                Runtime    = movieViewModel.Runtime,
                Genre      = movieViewModel.Genre,
                Director   = movieViewModel.Director,
                Plot       = movieViewModel.Plot,
                Poster     = movieViewModel.Poster,
                ImdbRating = float.Parse(movieViewModel.ImdbRating),
                ScreenShot = movieViewModel.ScreenShot
            };

            var result = _moviesLogic.Update(movieModelBLL);

            if (result)
            {
                TempData["SuccessMessage"] = "Movie created successfully";
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["ErrorMessage"] = "Could not save movie";
                return(RedirectToAction("EditOrCreateMovie", movieViewModel.Id));
            }
        }
Example #3
0
        public ActionResult Edit(Movie movie)
        {
            var updated = MoviesLogic.Update(movie);

            return(View(updated));
        }