public async Task <IActionResult> Edit(int id, [Bind("Id,BalanceId,Category,Description,Amount,Date")] Spending spending) { if (id != spending.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (await _repository.Update(spending) != null) { return(RedirectToAction(nameof(Details), "Balance", new { id = spending.BalanceId }, null)); } } catch (DbUpdateConcurrencyException) { if (!_repository.SpendingExists(spending.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(spending)); }