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