// GET: Actor/Edit/5 public ActionResult Edit(int id) { var service = CreateActorService(); var detail = service.GetActorById(id); var model = new ActorEdit { ActorId = detail.ActorId, Name = detail.Name }; return(View(model)); }
public bool UpdateActor(ActorEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Actors .Single(e => e.ActorId == model.ActorId && e.UserId == _userId); entity.ActorId = model.ActorId; entity.Name = model.Name; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, ActorEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ActorId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateActorService(); if (service.UpdateActor(model)) { return(RedirectToAction("Index")); } return(View(model)); }