public async Task<ActionResult> Skapa(NewsPost newsPost) { if (ModelState.IsValid) { newsPost.CreatedOn = DateTime.Now; db.NewsPosts.Add(newsPost); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(newsPost); }
public async Task<ActionResult> Redigera(NewsPost newsPost) { if (ModelState.IsValid) { db.Entry(newsPost).State = EntityState.Modified; await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(newsPost); }