Ejemplo n.º 1
0
        public async Task <JsonResult> RequestLoan_Post(LoanRequestNewDTO loanRequest)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new HttpException((int)HttpStatusCode.BadRequest, ConstantHelper.KEY_IN_REQUIRED_FIELD);
                }

                Response.StatusCode = 200;
                var account = await handler.CreateLoanRequest(loanRequest, Request);

                return(Json(account.acct_AccountID, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                if (ex.Message == ConstantHelper.ALREADY_REQUEST_LOAN ||
                    ex.Message == ConstantHelper.KEY_IN_REQUIRED_FIELD ||
                    ex.Message == ConstantHelper.INVALID_PIN ||
                    ex.Message == ConstantHelper.PIN_EXPIRED)
                {
                    Response.StatusCode = 400;
                }
                else
                {
                    Response.StatusCode = 500;
                }
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }