public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Blog).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BlogExists(Blog.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Blog.Add(Blog); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Blog = await _context.Blog.FindAsync(id); if (Blog != null) { _context.Blog.Remove(Blog); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Blog = await _context.Blog.FirstOrDefaultAsync(m => m.ID == id); Blog.Hits += 1; _context.Attach(Blog).State = EntityState.Modified; await _context.SaveChangesAsync(); if (Blog == null) { return(NotFound()); } return(Page()); }