コード例 #1
0
 public async Task <ActionResult> Save(CheckLoanRequestEditDTO checkLoanRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Response.StatusCode = 200;
             return(Json(await handler.Save(checkLoanRequest), JsonRequestBehavior.AllowGet));
         }
         return(null);
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #2
0
        //-> Save
        public async Task <CheckLoanRequestViewDTO> Save(CheckLoanRequestEditDTO checkLoanRequest)
        {
            checkLoanRequest = StringHelper.TrimStringProperties(checkLoanRequest);

            tblAccount account = await db.tblAccounts.FirstOrDefaultAsync(a => a.acct_Deleted == null && a.acct_AccountID == checkLoanRequest.accountID);

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

            /*string tmp = Helpers.StringHelper.str2Date(checkLoanRequest.acct_DOB.ToString());
             * if(tmp != "")
             * checkLoanRequest.acct_DOB = DateTime.Parse(tmp);*/
            account = (tblAccount)MappingHelper.MapDTOToDBClass <CheckLoanRequestEditDTO, tblAccount>(checkLoanRequest, account);

            account.acct_UpdatedDate = DateTime.Now;
            await db.SaveChangesAsync();

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