public async Task<IActionResult> Create(Blog blog) { if (ModelState.IsValid) { blog.DateCreated = DateTime.UtcNow; _context.Blogs.Add(blog); await _context.SaveChangesAsync(); return RedirectToAction("Index"); } return View(blog); }
public async Task<IActionResult> Edit(Blog blog) { if (ModelState.IsValid) { _context.Update(blog); await _context.SaveChangesAsync(); return RedirectToAction("Index"); } return View(blog); }