コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }