コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #4
0
        public ActionResult Add()
        {
            Movie movie = new Movie();

            return View(movie);
        }