public IActionResult Create(TransactionEditViewModel model) { if (ModelState.IsValid) { var newTransaction = new Transaction(); newTransaction.Amount = model.Amount; newTransaction.Date = model.Date; newTransaction.Type = model.Type; newTransaction.UserId = _currentUserId; newTransaction.Wallet = _transactionData.GetWalletBasedOnName(model.Wallet); newTransaction.Category = _transactionData.GetCategoryBasedOnName(model.Category); newTransaction = _transactionData.Add(newTransaction); _transactionData.Commit(); return(RedirectToAction("Details", new { id = newTransaction.Id })); } return(View()); }
public IActionResult Create(Wallet model) { if (ModelState.IsValid) { var newWallet = new Wallet(); newWallet.Currency = model.Currency; newWallet.Name = model.Name; newWallet.UserId = _currentUserId; newWallet.Transactions = new List <Transaction>(); newWallet = _transactionData.Add(newWallet); _transactionData.Commit(); //return RedirectToAction("Details", new { id = newWallet.Id }); return(View()); } return(View()); }