Ejemplo n.º 1
0
        public JsonNetResult JsonMenus()
        {
            var mainMenus = new MainMenusModel
            {
                Menus       = new List <MenuModel>(),
                IsAdmin     = this.IsAdmin,
                UserAccount = UserContext.Account,
                UserName    = UserContext.Name
            };

            IList <SystemFunctionEntity> funs;

            if (this.IsAdmin)
            {
                funs = new List <SystemFunctionEntity>();
                funs.Add(new SystemFunctionService().GetSettingFunction());
            }
            else
            {
                if (this.UserContext.HospitalOrVendor)
                {
                    var hospitalId = string.IsNullOrEmpty(this.UserContext.CurrentHospital)
                        ? this.UserContext.RootUnitId : this.UserContext.CurrentHospital;
                    funs = new SystemFunctionService().GetUserFunctions(hospitalId, this.UserContext.UserId);
                }
                else
                {
                    funs = new SystemFunctionService().GetUserFunctions(this.UserContext.RootUnitId, this.UserContext.UserId);
                }
            }
            foreach (var fun in funs)
            {
                var menu = new MenuModel
                {
                    Id       = fun.Id,
                    Title    = fun.Title,
                    Url      = fun.Url,
                    SubMenus = new List <MenuModel>()
                };
                menu.SubMenus = fun.SubFunctions.Select(item => new MenuModel
                {
                    Id    = item.Id,
                    Title = item.Title,
                    Url   = item.Url
                }).ToList();

                mainMenus.Menus.Add(menu);
            }
            var loginInfo = LoginInfo();

            return(JsonNet(new ResponseResult(true, new { mainMenus, loginInfo })));
        }
Ejemplo n.º 2
0
        public PartialViewResult Menus()
        {
            var mainMenus = new MainMenusModel
            {
                Menus   = new List <MenuModel>(),
                IsAdmin = this.IsAdmin
            };

            IList <SystemFunctionEntity> funs;

            if (this.IsAdmin)
            {
                funs = new List <SystemFunctionEntity>();
                funs.Add(new SystemFunctionService().GetSettingFunction());
            }
            else
            {
                if (this.UserContext.HospitalOrVendor)
                {
                    var hospitalId = string.IsNullOrEmpty(this.UserContext.CurrentHospital)
                        ? this.UserContext.RootUnitId : this.UserContext.CurrentHospital;
                    funs = new SystemFunctionService().GetUserFunctions(hospitalId, this.UserContext.UserId);
                }
                else
                {
                    funs = new SystemFunctionService().GetUserFunctions(this.UserContext.RootUnitId, this.UserContext.UserId);
                }
            }

            foreach (var fun in funs)
            {
                var menu = new MenuModel
                {
                    Id       = fun.Id,
                    Title    = fun.Title,
                    Url      = fun.Url,
                    SubMenus = new List <MenuModel>()
                };
                menu.SubMenus = fun.SubFunctions.Select(item => new MenuModel
                {
                    Id    = item.Id,
                    Title = item.Title,
                    Url   = item.Url
                }).ToList();

                mainMenus.Menus.Add(menu);
            }

            return(PartialView("~/Views/Main/_Menus.cshtml", mainMenus));
        }