public ActionResult EditPost(Posts p, bool LinkPicEdit) { using (HelloBlogEntities db = new HelloBlogEntities()) { var item = db.Posts.Where(x => x.ID == p.ID).FirstOrDefault(); if (!LinkPicEdit) { checkPic(p); } item.PicImg = p.PicImg ?? item.PicImg; item.Title = p.Title ?? item.Title; item.Body = p.Body ?? item.Body; db.SaveChanges(); } return(RedirectToAction("EditPost")); }
public ActionResult AddNewPostToHB(Posts p, bool Today, bool LinkPic) { if (!LinkPic) { checkPic(p); } if (Today) { p.DateTime = DateTime.Now; } using (HelloBlogEntities db = new HelloBlogEntities()) { db.Posts.Add(p); db.SaveChanges(); } return(RedirectToAction("AddNewPostToHB")); }