public ActionResult Create(Category collection) { try { // TODO: Add insert logic here db.Category.Add(collection); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Delete(int id, Category collection) { try { // TODO: Add delete logic here Category obj = db.Category.FirstOrDefault(x => x.CategoryId == id); db.Category.Remove(obj); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Category collection) { try { // TODO: Add update logic here Category obj = db.Category.FirstOrDefault(x => x.CategoryId == id); obj.Name = collection.Name; db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }