public ActionResult Category(int?id, string E) { if (id > 0 && E == "D") { CM_Categories model = db.CM_Categories.Find(id); db.Entry(model).State = EntityState.Deleted; db.SaveChanges(); TempData["msg"] = "Deleted Sucessfully!"; return(RedirectToAction("CategoryDetails")); } else if (id > 0) { CM_Categories model = db.CM_Categories.Find(id); return(View(model)); } return(View()); }
public ActionResult Category(CM_Categories model, int?id) { if (ModelState.IsValid) { if (id > 0) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); TempData["msg"] = "Update Succussfully"; } else { db.CM_Categories.Add(model); db.SaveChanges(); ModelState.Clear(); TempData["msg"] = "Category Created Successfully"; } } return(RedirectToAction("CategoryDetails")); }