// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. 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")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Tasks.Add(TodoItem); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TodoItem = await _context.Tasks.FindAsync(id); if (TodoItem != null) { _context.Tasks.Remove(TodoItem); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task OnGetAsync() { var tasks = from x in _context.Tasks select x; if (!string.IsNullOrEmpty(SearchString)) { tasks = tasks.Where(t => t.Title.Contains(SearchString) || t.Description.Contains(SearchString)); } Tasks = await tasks.ToListAsync(); ExpirationChecker expirationChecker = new ExpirationChecker((List <TodoItem>)Tasks); expirationChecker.Expire(); _ = await _context.SaveChangesAsync(); _progress.Count(); }