Пример #1
0
        public IHttpActionResult DeleteRole(DeleteRoleInput input)
        {
            Init();
            input.AccessToken = ApiSession.AccessToken;
            DeleteRoleOutput output = _rolesSvc.DeleteRole(input);

            return(Ok(output));
        }
Пример #2
0
        public ResponseInfoModel Delete([FromBody] DeleteRoleInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                int[] idInts = ConvertStringToIntArr(input.ids);
                if (_userRoleService.GetList(a => idInts.Contains(a.RoleID)).Any())
                {
                    throw new UserFriendlyException("角色下有用户不可删除");
                }

                if (!_roleService.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/role/delete", LocalizationConst.DeleteFail);
            }
            return(json);
        }
Пример #3
0
        public DeleteRoleOutput DeleteRole(DeleteRoleInput input)
        {
            try
            {
                RestHTTP    http = new RestHTTP();
                RestRequest req  = new RestRequest("api/roles/delete", RestSharp.Method.DELETE);
                req.AddHeader("Content-Type", "application/json");
                req.AddHeader("Authorization", "Bearer " + input.AccessToken);
                req.AddJsonBody(input);
                DeleteRoleOutput response = http.HttpPost <DeleteRoleOutput>(req);

                return(response);
            }
            catch (Exception ex)
            {
                WriteLogFile.Append("DeleteRole : ");
                WriteLogFile.Append(ex.Message);
                WriteLogFile.Append(ex.StackTrace);
            }
            return(null);
        }
Пример #4
0
        public async Task <DeleteRoleOutput> DeleteRole(DeleteRoleInput input)
        {
            _roleManager.DeleteRole(input.Id);

            return(new DeleteRoleOutput());
        }
Пример #5
0
        public DeleteRoleOutput DeleteRole(DeleteRoleInput input)
        {
            _roleService.DeleteRole(input.RoleId);

            return(new DeleteRoleOutput());
        }