Example #1
0
 public ActionResult Add(Movie movieFromView)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MovieDBContext())
         {
             db.Movies.Add(movieFromView);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(movieFromView);
 }
Example #2
0
 public ActionResult Delete(Movie movieToDelete)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MovieDBContext())
         {
             db.Entry(movieToDelete).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(movieToDelete);
 }
Example #3
0
 public ActionResult Edit(Movie movieToUpdate)
 {
     if (ModelState.IsValid)
         {
             using (var db = new MovieDBContext())
             {
                 db.Entry(movieToUpdate).State = EntityState.Modified;
                 db.SaveChanges();
             }
             return RedirectToAction("Index");
         }
         return View(movieToUpdate);
 }
Example #4
0
        public ActionResult Add()
        {
            Movie movie = new Movie();

            return View(movie);
        }