示例#1
0
 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);
 }
示例#2
0
 public async Task<IActionResult> Edit(Blog blog)
 {
     if (ModelState.IsValid)
     {
         _context.Update(blog);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     return View(blog);
 }