public void CreateTest() { //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" }; //Act var result1 = controller.Create(rightInput); //Assert Assert.IsTrue(result1); }
public ActionResult PostMovie(MovieViewModel movieViewModel) { if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false)) { return(RedirectToRoute(new { controller = "Home", action = "Index" })); } var movieModelBLL = new MovieModelBLL() { 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.Create(movieModelBLL); if (result) { TempData["SuccessMessage"] = "Movie created successfully"; return(RedirectToAction("Index")); } else { TempData["ErrorMessage"] = "Could not save movie"; return(RedirectToAction("EditOrCreateMovie")); } }