public async Task <IActionResult> Edit(int id, [Bind("ActualIncomeId,BudgetId,IncomeCategoryId,Amount")] ActualIncome actualIncome) { if (id != actualIncome.ActualIncomeId) { return(NotFound()); } if (ModelState.IsValid) { try { var user = await _userManager.GetUserAsync(HttpContext.User); int BudgetKey = HttpContext.Session.GetInt32("budgetKey") ?? default(int); actualIncome.BudgetId = BudgetKey; _context.Update(actualIncome); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActualIncomeExists(actualIncome.ActualIncomeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(actualIncome)); }
public async Task <IActionResult> Create([Bind("ActualIncomeId,BudgetId,IncomeCategoryId,Amount")] ActualIncome actualIncome) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(HttpContext.User); int BudgetKey = HttpContext.Session.GetInt32("budgetKey") ?? default(int); actualIncome.BudgetId = BudgetKey; _context.Add(actualIncome); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(actualIncome)); }