public async Task <ActionResult> SubmitRequest(LoanRequestSubmitStatusDTO loanRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Response.StatusCode = 200;
             return(Json(await handler.SubmitRequest(loanRequest), JsonRequestBehavior.AllowGet));
         }
         Response.StatusCode = 410;
         return(null);
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }
        /*
         * //-> SubmitRequest
         * public async Task<CheckLoanRequestViewDTO> SubmitRequest(int accountID, string status)
         * {
         *  tblAccount account = await db.tblAccounts.FirstOrDefaultAsync(a => a.deleted == null && a.id == accountID);
         *  if (account == null)
         *      throw new HttpException((int)HttpStatusCode.NotFound, "This record has been deleted");
         *
         *  account.updatedDate = DateTime.Now;
         *  account.status = status;
         *
         *  //-- update submit for approval status here
         *  //-- in Check Loan request form add status ; pending; submit for approval; approved, reject
         *  await db.SaveChangesAsync();
         *  return await SelectByID(account.id);
         * }
         */

        public async Task <CheckLoanRequestViewDTO> SubmitRequest(LoanRequestSubmitStatusDTO loanRequestDTO)
        {
            tblAccount account = await db.tblAccounts.FirstOrDefaultAsync(a => a.acct_Deleted == null && a.acct_AccountID == loanRequestDTO.accountID);

            if (account == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "This record has been deleted");
            }

            account = (tblAccount)MappingHelper.MapDTOToDBClass <LoanRequestSubmitStatusDTO, tblAccount>(loanRequestDTO, account);
            account.acct_UpdatedDate = DateTime.Now;
            var tblLoan = db.tblLoanRequests.FirstOrDefault(x => x.loan_Deleted == null &&
                                                            (x.loan_Status.ToLower() != "approved" && x.loan_Status.ToLower() != "rejected") &&
                                                            x.loan_AccountID == account.acct_AccountID);

            if (tblLoan != null)
            {
                tblLoan.loan_Status       = loanRequestDTO.status;
                tblLoan.loan_RejectReason = loanRequestDTO.reasonReject;
            }
            await db.SaveChangesAsync();

            return(await SelectByID(account.acct_AccountID));
        }