// To protect from overposting attacks, please 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(Category).State = EntityState.Modified; Category.ModifiedDate = DateTime.Now; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(Category.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id) { if (!ModelState.IsValid) { PopulateCategoriesDropdownList(_context, Post.Category); return(Page()); } _context.Attach(Post).State = EntityState.Modified; try { Post.ModifiedDate = DateTime.Now; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(Post.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }