public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(RandomFact).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RandomFactExists(RandomFact.RandomFactId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.RandomFact.Add(RandomFact); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } RandomFact = await _context.RandomFact.FindAsync(id); if (RandomFact != null) { _context.RandomFact.Remove(RandomFact); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }