public ActionResult Delete(int id, IndividualViewModel model) { try { var repository = new IndividualRepository(context); var individual = MapperHelper.Map <Individual>(model); repository.Delete(individual); context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { var repository = new IndividualRepository(context); var entity = repository.Find(id); repository.Delete(entity); context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View(new IndividualViewModel())); } }
public ActionResult Delete(int id, IndividualViewModel model) { try { var repo = new IndividualRepository(context); //if (ModelState.IsValid) //{ var individual = MapperHelpers.Map <Individual>(model); repo.Delete(individual); context.SaveChanges(); //} // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }