public ActionResult Create_POST()
 {
     var movieToCreate = new Movie();
     this.UpdateModel(movieToCreate, new string[] {"Title", "Director", "DateReleased"});
     // Add movie to database
     return RedirectToAction("Index");
 }
 public ActionResult Create(FormCollection collection)
 {
     var movieToCreate = new Movie();
     this.UpdateModel(movieToCreate, collection.ToValueProvider());
     // Insert movie into database
     return RedirectToAction("Index");
 }
        public ActionResult Create(Movie movieToCreate)
        {
            if (ModelState.IsValid) {
                _repository.Add<Movie>(movieToCreate);
                _repository.SaveChanges();

                return RedirectToAction("Index");
            }
            return View();
        }
        public ActionResult Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(movie);
        }
        public ActionResult Create(Movie movie)
        {
            movie.userId = User.Identity.Name;
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(movie);
        }
 public string Create(Movie movieToCreate)
 {
     try
     {
         _entities.AddToMovieSet(movieToCreate);
         _entities.SaveChanges();
         return "Inserted new movie " + movieToCreate.Title;
     }
     catch
     {
         return "Could not insert movie " + movieToCreate.Title;
     }
 }
        public bool CreateMovie(Movie movieToCreate)
        {
            // validate
            if (movieToCreate.Title.Trim().Length == 0)
                _modelState.AddModelError("Title", "Title is required.");
            if (movieToCreate.Title.IndexOf("r") > 0)
                _modelState.AddModelError("Title", "Title cannot contain the letter r.");
            if (movieToCreate.Director.Trim().Length == 0)
                _modelState.AddModelError("Director", "Director is required.");
            if (!_modelState.IsValid)
                return false;

            _repository.CreateMovie(movieToCreate);
            return true;
        }
 public ActionResult Edit(Movie movie)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movie).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(movie);
 }
 public abstract void CreateMovie(Movie movieToCreate);
Ejemplo n.º 10
0
 public abstract void CreateMovie(Movie movieToCreate);
        public ActionResult Edit(Movie movieToEdit)
        {
            if (ModelState.IsValid) {
                var originalMovie = _repository.Find<Movie>(movieToEdit.Id);
                originalMovie.Title = movieToEdit.Title;
                originalMovie.Director = movieToEdit.Director;
                _repository.SaveChanges();

                return RedirectToAction("Index");
            }
            return View();
        }
 public void CreateMovie(Movie movieToCreate)
 {
     _entities.AddToMovieSet(movieToCreate);
     _entities.SaveChanges();
 }
 public override void CreateMovie(Movie movieToCreate)
 {
     _entities.AddToMovieSet(movieToCreate);
     _entities.SaveChanges();
     _cache.Remove("movies");
 }
 public void CreateMovie(Movie movieToCreate)
 {
 }