public ActionResult Edit(int id, TransactionsViewModel model) { try { _transactionLogic.UpdateTransaction(id, model); _accountLogic.RefreshAccountBalance(model.AccountId); return(RedirectToAction("Index", "Transaction", new{ id = model.AccountId })); } catch { return(View("~/Views/Transaction/EditTransaction.cshtml", model)); } }
public async void Save() { if (IsEdit) { await TransactionLogic.UpdateTransaction(_transactionRepository.Selected); } else { await TransactionLogic.SaveTransaction(_transactionRepository.Selected, RefreshRealtedList); } ((Frame)Window.Current.Content).GoBack(); }
public void UpdateTransactionTest() { //Arrange var mockUnitOfWork = new Mock <IUnitOfWork>(); var transaction = new Transaction(); mockUnitOfWork.Setup(un => un.TransactionRepository.Update(It.IsAny <Transaction>())); mockUnitOfWork.Setup(un => un.Save()); ITransactionLogic transactionLogic = new TransactionLogic(mockUnitOfWork.Object); transaction.StockQuantity = 10000; var result = transactionLogic.UpdateTransaction(transaction); mockUnitOfWork.Verify(un => un.TransactionRepository.Update(It.IsAny <Transaction>()), Times.Once()); mockUnitOfWork.Verify(un => un.Save(), Times.Once()); Assert.True(result); }