public PartialViewResult AdminMenu() { try { CSF_MVCEntities entities = new CSF_MVCEntities(); CSF_Users_DAO objUserDao = new CSF_Users_DAO(); string username = HttpContext.User.Identity.Name; int intGuestGroup = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["IDGuestGroup"]); List <int> lRoleID = objUserDao.GetRoleIDByUserName(username, intGuestGroup); string stringRoleID = String.Join(",", lRoleID); // List <CSF_Pages> listAllPage = new List <CSF_Pages>(); if (username.Trim().ToLower() != "host") { var lPageActiveID = entities.CSF_Pages_GetPageByRoleID(stringRoleID).Select(x => (int)x.id).ToList(); listAllPage = entities.CSF_Pages.Where(x => lPageActiveID.Contains(x.ID) && x.IsAdmin == true).OrderBy(x => x.Order).ToList(); } else { listAllPage = entities.CSF_Pages.Where(x => x.IsAdmin == true && x.IsBlank == false && x.IsActive == true).OrderBy(x => x.Order).ToList(); } // string stringMenu = buildTreeMenu(listAllPage); MainMenu mainMenu = new MainMenu(); mainMenu.stringMenu = stringMenu; return(PartialView(mainMenu)); } catch (Exception ex) { Logs.WriteLog(ex); return(PartialView()); } }
public PartialViewResult MainMenu() { try { ViewBag.URLIMAGE = System.Configuration.ConfigurationManager.AppSettings["UrlImage"]; int intGuestGroup = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["IDGuestGroup"]); CSF_MVCEntities entities = new CSF_MVCEntities(); CSF_Users_DAO objUserDao = new CSF_Users_DAO(); string username = HttpContext.User.Identity.Name; List<int> lRoleID = objUserDao.GetRoleIDByUserName(username, intGuestGroup); string stringRoleID = String.Join(",", lRoleID); // List<CSF_Pages> listAllPage = new List<CSF_Pages>(); if (username.Trim().ToLower() != "host") { var lPageActiveID = entities.CSF_Pages_GetPageByRoleID(stringRoleID).Select(x => (int)x.id).ToList(); listAllPage = entities.CSF_Pages.Where(x => lPageActiveID.Contains(x.ID) && x.IsAdmin == false).OrderBy(x => x.Order).ToList(); } else { listAllPage = entities.CSF_Pages.Where(x => x.IsAdmin == false && x.IsBlank == false && x.IsActive == true).OrderBy(x => x.Order).ToList(); } // int sanphamtronggio = 0; if (Session["cart"] != null) { List<ShoppingCart> lCart = (List<ShoppingCart>)Session["cart"]; sanphamtronggio = lCart.Count(); } string stringMenu = buildTreeMenu(listAllPage, sanphamtronggio); MainMenu mainMenu = new MainMenu(); mainMenu.stringMenu = stringMenu; return PartialView(mainMenu); } catch (Exception ex) { Logs.WriteLog(ex); return PartialView(); } }