public ResponseInfoModel GetInfo(int ID) { ResponseInfoModel json = new ResponseInfoModel() { Success = 1, Result = new object() }; try { var role = _roleService.Get(ID); var navlist = _navgationService.GetList(a => true).OrderBy(a => a.OrderID).MapTo <List <GetRoleNavgationListOutput> >(); var categoryList = _articleCategoryService.GetList(a => true).OrderBy(a => a.OrderID).MapTo <List <GetRoleCategoryListOutput> >(); var actionList = _actionService.GetList(a => true); Dictionary <string, string> actionDictionary = new Dictionary <string, string>(); foreach (var cmsAction in actionList) { actionDictionary.Add(cmsAction.ActionCode, cmsAction.ActionName); } foreach (var navgationListOutput in navlist) { navgationListOutput.ActionsName = ConvertToName(actionDictionary, navgationListOutput.Actions); navgationListOutput.SelActions = _roleService.GetSelectNavActions(ID, navgationListOutput.NavName); } foreach (var categoryListOutput in categoryList) { categoryListOutput.SelActions = _roleService.GetSelCategoryActions(ID, categoryListOutput.ID); } List <GetRoleNavgationListOutput> navnewList = new List <GetRoleNavgationListOutput>(); GetChild(navlist, navnewList, 0, 0); List <GetRoleCategoryListOutput> catenewList = new List <GetRoleCategoryListOutput>(); GetChild(categoryList, catenewList, 0, 0); if (role != null) { var output = role.MapTo <GetRoleOutput>(); output.Navlist = navnewList; output.Categorylist = catenewList; json.Result = output; } } catch (Exception e) { DisposeUserFriendlyException(e, ref json, "api/role/getInfo", LocalizationConst.QueryFail); } return(json); }
public ResponseInfoModel Delete([FromBody] DeleteNavgationInput input) { ResponseInfoModel json = new ResponseInfoModel() { Success = 1, Result = new object() }; try { int[] idInts = ConvertStringToIntArr(input.IDs); if (_navgationService.GetList(a => idInts.Contains(a.ParentId)).Any()) { throw new UserFriendlyException("存在下级不能删除"); } if (!_navgationService.Delete(a => idInts.Contains(a.ID))) { json.Success = 0; json.Result = LocalizationConst.DeleteFail; } else { foreach (var id in idInts) { _logService.Insert(new Log() { ActionContent = LocalizationConst.Delete, SourceType = _moduleName, SourceID = id, LogUserID = input.UserID, LogTime = DateTime.Now, LogIPAddress = IPHelper.GetIPAddress, }); } } } catch (Exception e) { DisposeUserFriendlyException(e, ref json, "api/navgation/delete", LocalizationConst.DeleteFail); } return(json); }