示例#1
0
        public IHttpActionResult Add(AddCreditRequest request)
        {
            try
            {
//                if (!ModelState.IsValid)
//                {
//                    return BadRequest(ModelState);
//                }

                var baseLocalhostUrl = String.Format("{0}://{1}", Request.RequestUri.Scheme, Request.RequestUri.Authority);
                var baseUrl          = System.Web.Hosting.HostingEnvironment.MapPath("~/");
                var militaryArr      = request.MilitaryId != null?Convert.FromBase64String(request.MilitaryId) : null;

                var creditRequestResult = _iCreditRequestService.Add(Mapper.Map <DomainCreditRequest>(request),
                                                                     militaryArr, Convert.FromBase64String(request.IncomeCertificate),
                                                                     request.Email, baseUrl, baseLocalhostUrl, ModelState);

                if (creditRequestResult.ModelState != null && !creditRequestResult.ModelState.IsValid)
                {
                    return(BadRequest(creditRequestResult.ModelState));
                }

                return(Ok(creditRequestResult.DocPath));
            }
            catch (BankClientException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }