示例#1
0
        public HttpResponseMessage ApproveAgent([FromBody] ApproveAgentRequest request)
        {
            _logInfo.Info(string.Format("微信审批代理人接口请求串:{0},参数:{1}", Request.RequestUri, request.ToJson()));
            var viewModel = new BaseViewModel();

            if (!ModelState.IsValid)
            {
                viewModel.BusinessStatus = -10000;
                string msg = ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + (item.Errors[0].ErrorMessage + ";   "));
                viewModel.StatusMessage = "输入参数错误," + msg;
                return(viewModel.ResponseToJson());
            }
            var response = _agentService.ApproveAgent(request, Request.GetQueryNameValuePairs());

            if (response.Status == HttpStatusCode.BadRequest || response.Status == HttpStatusCode.Forbidden)
            {
                viewModel.BusinessStatus = -10001;
                viewModel.StatusMessage  = "参数校验错误,请检查您的校验码";
                return(viewModel.ResponseToJson());
            }
            if (response.Status == HttpStatusCode.InternalServerError)
            {
                viewModel.BusinessStatus = -10003;
                viewModel.StatusMessage  = "服务发生异常";
            }
            if (response.Status == HttpStatusCode.OK)
            {
                viewModel.BusinessStatus = 1;
                viewModel.StatusMessage  = "修改成功";
            }
            else
            {
                viewModel.BusinessStatus = 0;
                viewModel.StatusMessage  = "修改失败";
            }
            return(viewModel.ResponseToJson());
        }