public async Task <IActionResult> EditPaycheck(EditViewModel model) { if (ModelState.IsValid) { try { await _itemGenerator.EditPaycheckAndPushToDbAsync(model); decimal amountChanged = model.PreviousAmount - model.Amount; await _userEditor.SubtractCurrentMoney(amountChanged); await _userEditor.SubtractBudgetedForNeeds(amountChanged * .5m); await _userEditor.SubtractBudgetedForWants(amountChanged * .3m); await _userEditor.SubtractBudgetedForSavings(amountChanged * .2m); await _userEditor.SubtractFromAllTimeEarned(amountChanged); return(RedirectToAction("Index", "Dashboard")); } catch { return(BadRequest()); } } else { return(View(model)); } }
public async Task <IActionResult> AddSaving(AddViewModel model) { if (ModelState.IsValid) { try { await _itemGenerator.CreateSavingAndPushToDbAsync(model); await _userEditor.SubtractCurrentMoney(model.Amount); await _userEditor.SubtractBudgetedForSavings(model.Amount); await _userEditor.AddToAllTimeSpent(model.Amount); return(RedirectToAction("Index", "Dashboard")); } catch { return(BadRequest()); } } return(BadRequest()); }