// GET: Admin/Menu/Edit/5 public ActionResult Edit(long id) { MenuDao dbMenu = new MenuDao(); MenuTypeDao dbMenuType = new MenuTypeDao(); Menu menu = null; try { menu = dbMenu.FindByID(id); var items = GetClientMenuViewModel(); ViewBag.ParentID = new SelectList(items, "ID", "Text", menu.ParentID); ViewBag.GroupID = new SelectList(dbMenuType.ToList(), "ID", "Name"); } catch { ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage); } return(View(menu)); }
public ActionResult Edit(Menu collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuDao bdDao = new MenuDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.UpdatedBy = us.UserName; collection.UpdatedDate = Hepper.GetDateServer(); MenuDao dbMenu = new MenuDao(); MenuTypeDao dbMenuType = new MenuTypeDao(); var items = GetClientMenuViewModel(); ViewBag.ParentID = new SelectList(items, "ID", "Text"); ViewBag.GroupID = new SelectList(dbMenuType.ToList(), "ID", "Name"); if (bdDao.Update(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không cập nhật được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
// GET: Admin/MenuType public ActionResult Index() { MenuTypeDao bdDao = new MenuTypeDao(); return(View(bdDao.ToList())); }
private void PopulateGroupIDDropDownList(object selectedParent = null) { MenuTypeDao dbDao = new MenuTypeDao(); ViewBag.Groups = new SelectList(dbDao.ToList(), "ID", "Name", selectedParent); }