/// <summary>
 /// Update existing movie in database.
 /// </summary>
 /// <param name="movieToUpdate"></param>
 public void UpdateMovie(Movie movieToUpdate)
 {
     var originalMovie = this.FindMovie(movieToUpdate.Id);
     originalMovie.Title = movieToUpdate.Title;
     originalMovie.Director = movieToUpdate.Director;
     _db.SaveChanges();
 }
        public ActionResult Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                _repo.Add<Movie>(movie);
                _repo.SaveChanges();

                return RedirectToAction("Index");
            }

            return View();
        }
        public ActionResult Edit(Movie movie)
        {
            if (ModelState.IsValid)
            {
                var originalMovie = _repo.Find<Movie>(movie.Id);
                originalMovie.Title = movie.Title;
                originalMovie.Director = movie.Director;
                _repo.SaveChanges();

                return RedirectToAction("Index");
            }

            return View();
        }
Example #4
0
 /// <summary>
 /// Add new movie to db.
 /// </summary>
 /// <param name="movieToCreate"></param>
 public void CreateMovie(Movie movieToCreate)
 {
     _db.Movies.Add(movieToCreate);
     _db.SaveChanges();
 }
 /// <summary>
 /// Add new movie to db.
 /// </summary>
 /// <param name="movieToCreate"></param>
 public void CreateMovie(Movie movieToCreate)
 {
     _db.Movies.Add(movieToCreate);
     _db.SaveChanges();
 }