public void AddActor(Actor actorToAdd) { using (var db = new MovieReviewsEntities()) { db.Actors.Add(actorToAdd); db.SaveChanges(); } }
public ActionResult Edit(Actor actor) { if (ModelState.IsValid) { actorActionEvent.UpdateActor(actor); return RedirectToAction("Index", new { idOfChangedActor = actor.ActorID }); } return View(actor); }
public void UpdateActor(Actor actorToEdit) { using (var db = new MovieReviewsEntities()) { db.Actors.Attach(actorToEdit); db.Entry<Actor>(actorToEdit).State = System.Data.EntityState.Modified; db.SaveChanges(); } }
public ActionResult Edit(int id) { actor = actorActionEvent.Find(id); if (actor == null) { return HttpNotFound(); } return View(actor); }
public void DeleteActor(int actorId) { using (var db = new MovieReviewsEntities()) { var actorToDelete = new Actor { ActorID = actorId }; db.Actors.Attach(actorToDelete); db.Actors.Remove(actorToDelete); db.SaveChanges(); } }
public ActionResult DeleteConfirmation(int actorId) { actor = actorActionEvent.Find(actorId); return View(actor); }
public ActionResult Add(Actor model) { actorActionEvent.AddActor(model); return RedirectToAction("index", new { idOfChangedActor = model.ActorID }); }