コード例 #1
0
 public ActionResult Delete(Actor actorToDelete)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MovieDBContext())
         {
             db.Entry(actorToDelete).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(actorToDelete);
 }
コード例 #2
0
 public ActionResult Add(Actor actorFromView)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MovieDBContext())
         {
             db.Actors.Add(actorFromView);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(actorFromView);
 }
コード例 #3
0
 public ActionResult Edit(Actor actorToUpdate)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MovieDBContext())
         {
             db.Entry(actorToUpdate).State = EntityState.Modified;
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(actorToUpdate);
 }