public ActionResult Create(HttpPostedFileBase file, tbl_Menu _menu, int? ParentId) { try { tbl_Menu _tbl_menu = new tbl_Menu(); _tbl_menu.MenuName = _menu.MenuName; _tbl_menu.Status = 1; _tbl_menu.priority = _menu.priority; if(ParentId==null) { _tbl_menu.ParentId = 0; } else _tbl_menu.ParentId = _menu.ParentId; _tbl_menu.Section = _menu.Section; _tbl_menu.url = _menu.url; db.tbl_Menu.Add(_tbl_menu); db.SaveChanges(); return RedirectToAction("Index","Menu"); } catch { return View(); } }
public ActionResult Edit(HttpPostedFileBase file, tbl_Menu _Menu, int? id,int? Status, int? ParentId) { try { tbl_Menu menu = db.tbl_Menu.Where(x => x.MenuId == id).FirstOrDefault(); menu.MenuName = _Menu.MenuName; menu.Status = _Menu.Status; menu.priority = _Menu.priority; if(ParentId==null) { menu.ParentId = 0; } else menu.ParentId = ParentId; menu.Section = _Menu.Section; menu.url = _Menu.url; db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }