public ActionResult CarregarMenu(int MenuId, int IdiomaId)
        {
            MenuDAL dal = new MenuDAL();
            Menu menu = new Menu();

            int SiteId = 2;
            int UsuarioId = 1;
            //int IdiomaId = 1;

            var resposta = dal.Carregar(MenuId, IdiomaId, false);

            return Json(resposta, JsonRequestBehavior.AllowGet);
        }
Exemple #2
0
        /// <summary>
        /// 获取菜单树
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public List <MenuTree> getMenuTree(int userId)
        {
            List <MenuTree> menuTree = new List <MenuTree>();

            var menus      = new MenuDAL().Get();
            var authoritys = new UserAuthorityDAL().Get().Where(o => o.UserId == userId).OrderBy(o => o.MenuId).ToList().Distinct();
            var firstMenu  = menus.Where(o => o.MenuPid == "0").ToList();

            for (int i = 0; i < firstMenu.Count(); i++)
            {
                string menuid = firstMenu[i].MenuId;
                if (authoritys.Where(o => o.MenuId == menuid).Count() > 0)
                {
                    MenuTree        first  = new MenuTree();
                    List <MenuTree> childs = new List <MenuTree>();
                    first.name      = firstMenu[i].MenuName;
                    first.url       = firstMenu[i].MenuUrl;
                    first._class    = firstMenu[i].Class;
                    first.childs    = childs;
                    first.showChild = i == 0;

                    foreach (Menu item in menus.Where(o => o.MenuPid == menuid))
                    {
                        if (authoritys.Where(o => o.MenuId == item.MenuId).Count() > 0)
                        {
                            MenuTree second = new MenuTree();
                            second.name   = item.MenuName;
                            second.url    = item.MenuUrl;
                            second._class = item.Class;
                            childs.Add(second);
                        }
                    }
                    menuTree.Add(first);
                }
            }

            return(menuTree);
        }
Exemple #3
0
        public void CarregarMenuTree(int PublicacaoId)
        {
            var currentCulture = HttpContext.Current.Request.Cookies["lang"] != null ? HttpContext.Current.Request.Cookies["lang"].Value : "pt-BR";
            if (string.IsNullOrEmpty(currentCulture)) currentCulture = "pt-BR";
            int IdiomaId = Util.GetIdiomaId(currentCulture);

            var currentSite = HttpContext.Current.Request.Cookies["site"] != null ? HttpContext.Current.Request.Cookies["site"].Value : "2";
            if (string.IsNullOrEmpty(currentSite)) currentSite = "0";
            int SiteId = Convert.ToInt32(currentSite);

            var UsuarioId = HttpContext.Current.Request.Cookies["UsuarioId"] != null ? HttpContext.Current.Request.Cookies["UsuarioId"].Value : "0";
            var UsuarioNome = HttpContext.Current.Request.Cookies["UsuarioNome"] != null ? HttpContext.Current.Request.Cookies["UsuarioNome"].Value : "";

            MenuDAL dal = new MenuDAL();
            ListaMenuTree = new List<Menu>();

            if (this.ListaMenuInterna.Count > 0)
            {
                ListaMenuTree = dal.ListarMenuTree(IdiomaId, PublicacaoId);

                //Sempre exibir Home!
                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Home",
                    Rotulo = "Home"
                });
            }
            else if (Conteudo.PublicacaoTipoId == (int)Util.TIPOPUBLICACAO.EVENTO)
            {
                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Eventos/" + Conteudo.PublicacaoId + "/" + Util.GerarURLAmigavel(Conteudo.Detalhe.Titulo),
                    Rotulo = Conteudo.Detalhe.Titulo
                });

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Eventos",
                    Rotulo = "Eventos"
                });

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Home",
                    Rotulo = "Home"
                });
            }
            else if (Conteudo.PublicacaoTipoId == (int)Util.TIPOPUBLICACAO.NOTICIA)
            {
                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Noticias/" + Conteudo.PublicacaoId + "/" + Util.GerarURLAmigavel(Conteudo.Detalhe.Titulo),
                    Rotulo = Conteudo.Detalhe.Titulo
                });

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Noticias",
                    Rotulo = "Noticias"
                });

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Home",
                    Rotulo = "Home"
                });
            }
            else if (Conteudo.PublicacaoTipoId == (int)Util.TIPOPUBLICACAO.MATERIA)
            {
                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Materia/" + Conteudo.PublicacaoId + "/" + Util.GerarURLAmigavel(Conteudo.Detalhe.Titulo),
                    Rotulo = Conteudo.Detalhe.Titulo
                });

                //ListaMenuTree.Add(new Menu()
                //{
                //    MenuTipoAcaoId = 1,
                //    LinkURL = "Matérias",
                //    Rotulo = "Matérias"
                //});

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Home",
                    Rotulo = "Home"
                });
            }
            else if (Conteudo.PublicacaoTipoId == (int)Util.TIPOPUBLICACAO.PAGINA)
            {

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Interna/" + Conteudo.PublicacaoId + "/" + Util.GerarURLAmigavel(Conteudo.Detalhe.Titulo),
                    Rotulo = Conteudo.Detalhe.Titulo
                });

                ListaMenuTree.Add(new Menu()
                {
                    MenuTipoAcaoId = 1,
                    LinkURL = "Home",
                    Rotulo = "Home"
                });
            }
            else
            {
                ListaMenuTree = dal.ListarMenuTree(IdiomaId, PublicacaoId);
            }
        }
Exemple #4
0
        public void CarregarMenuInterna(int PublicacaoId)
        {
            var currentCulture = HttpContext.Current.Request.Cookies["lang"] != null ? HttpContext.Current.Request.Cookies["lang"].Value : "pt-BR";
            if (string.IsNullOrEmpty(currentCulture)) currentCulture = "pt-BR";
            int IdiomaId = Util.GetIdiomaId(currentCulture);

            var currentSite = HttpContext.Current.Request.Cookies["site"] != null ? HttpContext.Current.Request.Cookies["site"].Value : "2";
            if (string.IsNullOrEmpty(currentSite)) currentSite = "0";
            int SiteId = Convert.ToInt32(currentSite);

            var UsuarioId = HttpContext.Current.Request.Cookies["UsuarioId"] != null ? HttpContext.Current.Request.Cookies["UsuarioId"].Value : "0";
            var UsuarioNome = HttpContext.Current.Request.Cookies["UsuarioNome"] != null ? HttpContext.Current.Request.Cookies["UsuarioNome"].Value : "";

            MenuDAL dal = new MenuDAL();

            ListaMenuInterna = dal.ListarMenu(SiteId, 1, IdiomaId, PublicacaoId);
        }
 public ActionResult ReposicionarMenu(int MenuId, int MenuPaiId, int Posicao)
 {
     MenuDAL dal = new MenuDAL();
     Menu menu = new Menu();
     menu.MenuId = MenuId;
     menu.MenuPaiId = MenuPaiId == 0 ? new Nullable<int>() : MenuPaiId;
     menu.Posicao = Posicao + 1;
     return Json(dal.Reposicionar(menu), JsonRequestBehavior.AllowGet);
 }
        public ActionResult ListarMenu(int MenuTipoId)
        {
            int SiteId = GetCurrentSite();
            int UsuarioId = 1;
            int IdiomaId = 1;

            //Eventos
            MenuDAL menuDAL = new MenuDAL();
            List<Menu> listaMenu = menuDAL.ListarMenu(SiteId, MenuTipoId, (int)Util.IDIOMA.PORTUGUES, null, true, Convert.ToInt32(UsuarioId), false);

            return Json(listaMenu, JsonRequestBehavior.AllowGet);
        }