Exemplo n.º 1
0
        public ActionResult Create(Post post)
        {
            if (ModelState.IsValid)
            {
                if (ModelState.IsValid)
                {
                    //added this to set the date to now, removed the date entry from the views
                    //seems an odd behaviour but it doesnt use SQL default when left blank
                    post.DateCreated = DateTime.Now;
                    db.Posts.Add(post);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }

            return View(post);
        }
Exemplo n.º 2
0
 public ActionResult Edit(Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(post);
 }