public bool Delete(GovItemVM item) { var db = new GuvnerContext(); var model = db.GovItems.FirstOrDefault(gi => gi.ID == item.ID); db.GovItems.Remove(model); return db.SaveChanges() != 0; }
public ActionResult Details(GovItemVM model) { if (ModelState.IsValid) { if (Repo.Save(model)) { return RedirectToAction("ShowGovItemOptions", new { type = model.GovItemTypeId }); } } return View(); }
public bool Save(GovItemVM item) { var db = new GuvnerContext(); if (item.ID == 0) { var m = Mapper.Map<GovItemVM, GovItem>(item); db.GovItems.Add(m); } else { var model = db.GovItems.FirstOrDefault(gi => gi.ID == item.ID); Mapper.Map<GovItemVM, GovItem>(item, model); } return db.SaveChanges() != 0; }