/** * Controller: Menus * Action: Index * List All menu system * Author: Le Dang Son * Date: 08/08/2012 */ public ActionResult Index() { int admin = base.Authentication(); if (admin == 0) { return Redirect("~/member/logout"); } else if (admin == 1) { base.LoadMenu(); List<Menus> listMenu = new FineArtContext().Menus.ToList(); ViewBag.Title += " Menus"; listMenu.ForEach(delegate(Menus menu) { if (menu.Controller == "") { menu.Controller = "Index"; } if (menu.Action == "") { menu.Action = "Index"; } Strings stringsLibs = new Strings(); menu.Controller = stringsLibs.Capacital(menu.Controller); menu.Action = stringsLibs.Capacital(menu.Action); }); ViewBag.listMenu = listMenu; return View(); } else { Session["errorContorllerAction"] = true; return Redirect("~/administrator"); } }
public ActionResult MenusRole(string id) { int admin = base.Authentication(); if (admin == 0) { return Redirect("~/member/logout"); } else if (admin == 1) { base.LoadMenu(); try { int idd = Convert.ToInt16(id); Roles role = new Roles(); role.ID = idd; role = role.GetRoleWithID(); List<Menus> listMenu = role.Menu.ToList(); listMenu.ForEach(delegate(Menus menu) { if (menu.Controller == "") { menu.Controller = "Index"; } if (menu.Action == "") { menu.Action = "Index"; } Strings stringsLibs = new Strings(); menu.Controller = stringsLibs.Capacital(menu.Controller); menu.Action = stringsLibs.Capacital(menu.Action); }); ViewBag.RoleID = idd; ViewBag.Title += " Menus for " + role.Name; ViewBag.listMenu = listMenu; } catch { } return View(); } else { Session["errorContorllerAction"] = true; return Redirect("~/administrator"); } }