public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(TodoItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoItemExists(TodoItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.TodoItems.Add(TodoItem); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } TodoItem = await _context.TodoItems.FindAsync(id); if (TodoItem != null) { _context.TodoItems.Remove(TodoItem); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <bool> SaveChangesAsync() { return((await _context.SaveChangesAsync()) > 0); }