コード例 #1
0
        public void CreateAccountingDetail(AccountingDetailViewModel createModel)
        {
            var accountBook = new AccountBook()
            {
                Id         = Guid.NewGuid(),
                Amounttt   = (int)createModel.Price,
                Categoryyy = (int)createModel.Category,
                Dateee     = createModel.Date,
                Remarkkk   = createModel.Description,
            };

            _accountBookRepository.Create(accountBook);
        }
コード例 #2
0
        public ActionResult Create(AccountingDetailViewModel newModel)
        {
            if (ModelState.IsValid)
            {
                try {
                    accountingService.CreateAccountingDetail(newModel);
                    accountingService.Save();
                } catch (Exception) {
                    //TODO:寫log
                    //導向錯誤頁
                    return(RedirectToAction("Error"));
                }
            }

            return(View("Index", newModel));
        }
コード例 #3
0
 public ActionResult CreateForAjax(AccountingDetailViewModel newModel)
 {
     if (ModelState.IsValid)
     {
         try {
             accountingService.CreateAccountingDetail(newModel);
             accountingService.Save();
             return(AccountingDetail());
         } catch (Exception) {
             //TODO:寫log
             return(Content("新增失敗!"));
         }
     }
     else
     {
         return(Content("資料驗證失敗!"));
     }
 }