public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(TransactionEntry).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionEntryExists(TransactionEntry.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["Categories"] = new SelectList(_context.Categories, "ID", "Title"); return(Page()); } BudgetEntry.ApplicationUserID = _userManager.GetUserId(User); BudgetEntry.CurrentBalance = BudgetEntry.Amount; _context.Budget.Add(BudgetEntry); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["Categories"] = new SelectList(_context.Categories, "ID", "Title"); //Types = ListTypes(); return(Page()); } TransactionEntry.ApplicationUserID = _userManager.GetUserId(User); _context.Transactions.Add(TransactionEntry); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } BudgetEntry = await _context.Budget.FindAsync(id); if (BudgetEntry != null) { _context.Budget.Remove(BudgetEntry); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }