Exemple #1
0
        public ResponseInfoModel List(int UserID)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                List <Navgation> list = new List <Navgation>();
                var user = _userService.Get(UserID);
                if (user == null)
                {
                    throw new UserFriendlyException(LocalizationConst.NoExist);
                }

                if (user.Type == 1)
                {
                    list = _navgationService.GetNoTrackingList(a => true).OrderBy(a => a.OrderID).ToList();
                }
                else
                {
                    string[] codes = _userService.GetPermNavCodes(UserID);
                    list = _navgationService.GetNoTrackingList(a => codes.Contains(a.NavName)).OrderBy(a => a.OrderID).ToList();
                }
                var outputlist = list.MapTo <List <GetPermissionNavListOutput> >();
                json.Result = outputlist;
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/permission/list", LocalizationConst.QueryFail);
            }
            return(json);
        }
        public ResponseInfoModel List()
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                var navgationList = _navgationService.GetNoTrackingList(a => true).OrderBy(a => a.OrderID).ToList();

                var outputList = navgationList.MapTo <List <GetNavgationListOutput> >();

                var actionList = _actionService.GetNoTrackingList(a => true);
                Dictionary <string, string> actionDictionary = new Dictionary <string, string>();
                foreach (var cmsAction in actionList)
                {
                    actionDictionary.Add(cmsAction.ActionCode, cmsAction.ActionName);
                }

                foreach (var output in outputList)
                {
                    output.ActionTypesName = ConvertToName(actionDictionary, output.ActionTypesName);
                }
                List <GetNavgationListOutput> newList = new List <GetNavgationListOutput>();
                GetChild(outputList, newList, 0, 0);
                json.Result = newList;
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/navgation/list", LocalizationConst.QueryFail);
            }
            return(json);
        }
Exemple #3
0
        public ResponseInfoModel FirstloadInfo()
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                var navList       = _navgationService.GetNoTrackingList(a => true).OrderBy(a => a.OrderID).ToList();
                var categoryList  = _articleCategoryService.GetList(a => true).OrderBy(a => a.OrderID).ToList();
                var outputNavList = navList.MapTo <List <GetLoadNavgationListOutput> >();

                var actionList = _actionService.GetNoTrackingList(a => true);
                Dictionary <string, string> actionDictionary = new Dictionary <string, string>();
                foreach (var cmsAction in actionList)
                {
                    actionDictionary.Add(cmsAction.ActionCode, cmsAction.ActionName);
                }

                foreach (var getLoadNavgationListOutput in outputNavList)
                {
                    getLoadNavgationListOutput.ActionsName = ConvertToName(actionDictionary, getLoadNavgationListOutput.Actions);
                }

                var outputCategoryList = categoryList.MapTo <List <GetLoadCategoryListOutput> >();

                List <GetLoadNavgationListOutput> navnewList = new List <GetLoadNavgationListOutput>();
                GetChild(outputNavList, navnewList, 0, 0);

                List <GetLoadCategoryListOutput> categorynewList = new List <GetLoadCategoryListOutput>();
                GetChild(outputCategoryList, categorynewList, 0, 0);

                json.Result = new GetLoadListOutput()
                {
                    navlist = navnewList, categorylist = categorynewList
                };
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/role/firstloadInfo", LocalizationConst.QueryFail);
            }
            return(json);
        }