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); }
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)); }
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("資料驗證失敗!")); } }