public ActionResult Create(Movie m)
 {
     if (ModelState.IsValid)
     {
         repository.Add(m);
         return RedirectToAction("Index");
     }
     return View(m);
 }
 public ActionResult Create(Movie newMovie)
 {
     if (ModelState.IsValid)
     {
         _moviesService.Add(newMovie);
         return RedirectToAction("Details", new { id = newMovie.ID });
     }
     else
     {
         return View(newMovie);
     }
 }
 public ActionResult EditPost(Movie updatedMovie)
 {
     if (ModelState.IsValid)
     {
         Movie bdMovie = _moviesService.Get(updatedMovie.ID);
         UpdateModel(bdMovie);
         _moviesService.Update(bdMovie);
         return RedirectToAction("Details", new { id = updatedMovie.ID });
     }
     else
     {
         return View(updatedMovie);
     }
 }
 public ActionResult Create(string Title)
 {
     Movie newMovie = new Movie();
     TryUpdateModel(newMovie);
     if (ModelState.IsValid)
     {
         _moviesService.Add(newMovie);
         return RedirectToAction("Details", new { id = newMovie.ID });
     }
     else
     {
         return View(newMovie);
     }
 }
 public ActionResult Create(string Title)
 {
     Movie newMovie = new Movie();
     TryUpdateModel(newMovie);
     if (ModelState.IsValid)
     {
         //newMovie.CreatedBy = Membership.GetUser().UserName;
         _moviesService.Add(newMovie);
         return RedirectToAction("Details", new { id = newMovie.ID });
     }
     else
     {
         return View(newMovie);
     }
 }
 public ActionResult Create(Movie newMovie, string fillButton) // alteracao: acrescentou-se 2o parametro com nome igual ao name do novo form submit
 {
     if (fillButton != null) // alteracao: acrescentou-se if
     {
         ModelState.Clear(); // alteracao: eliminar dados em memória, antes de procurar por novo titulo
         Movie movie = _moviesService.Search(newMovie.Title);
         return View(movie);
     }
     if (ModelState.IsValid)
     {
         _moviesService.Add(newMovie);
         return RedirectToAction("Details", new { id = newMovie.ID });
     }
     else
     {
         return View(newMovie);
     }
 }
 public ActionResult Create(Movie newMovie, string fillButton) // acrescentou-se 2o parametro com nome igual ao name do novo form submit
 {
     if (fillButton != null) // acrescentou-se if
     {
         Movie movie = _moviesService.Search(newMovie.Title);
         ModelState.Clear(); // 
         return View(movie);
     }
     if (ModelState.IsValid)
     {
         _moviesService.Add(newMovie);
         return RedirectToAction("Details", new { id = newMovie.ID });
     }
     else
     {
         return View(newMovie);
     }
 }
        public ActionResult Create(string Title, string fill)
        {

            if (!string.IsNullOrEmpty(fill))
            {
                return View(_moviesService.Search(Title));
            }

            var newMovie = new Movie();
            TryUpdateModel(newMovie);
            if (ModelState.IsValid)
            {
                _moviesService.Add(newMovie);
                return RedirectToAction("Details", new { id = newMovie.ID });
            }
            else
            {
                return View(newMovie);
            }
        }
        public ActionResult Create(string Title, string fill)
        {

            if (!string.IsNullOrEmpty(fill))
            {
                return View(_moviesService.Search(Title));
            }

            var newMovie = new Movie();
            TryUpdateModel(newMovie);
            if (ModelState.IsValid)
            {
                newMovie.Owner = _userService.GetAuthenticatedUser(User.Identity.Name);
                _moviesService.Add(newMovie);
                return RedirectToAction("Details", new { id = newMovie.ID });
            }
            else
            {
                return View(newMovie);
            }
        }
        public void ShouldReturnARedirectResultToDetailsViewOnCreatePostWhenMovieValid()
        {
            // Arrange
            Movie m = new Movie { ID = 1, Title = "SomeTitle" };
            // Act 
            var result = _controller.Create(m) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual(String.Empty, result.RouteName);
            Assert.AreEqual("Details", result.RouteValues["action"]);
            Assert.AreEqual(null, result.RouteValues["controller"]);
            Assert.AreEqual(m.ID, result.RouteValues["id"]);

        }
 public ActionResult Delete(Movie m)
 {
     _moviesService.Delete(m.ID);
     return RedirectToAction("Index");
 }