public ActionResult PostBlog(BLOGS blog) { if (Request.IsAuthenticated) { DateTime now = DateTime.Now; blog.USER_ID = User.Identity.GetUserId(); blog.VOID_IND = "n"; blog.CREATE_DT = now; db.Blog.Add(blog); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> doEdit(BLOGS blog) { int blogID = blog.BLOG_ID; DateTime now = DateTime.Now; var previousBlog = db.Blog.SingleOrDefault(b => b.BLOG_ID == blogID); if (Request.IsAuthenticated) { previousBlog.BLOG_TEXT = blog.BLOG_TEXT; previousBlog.TITLE = blog.TITLE; previousBlog.UPDATE_DT = now; previousBlog.CREATE_DT = blog.CREATE_DT; previousBlog.VOID_IND = "n"; await db.SaveChangesAsync(); return(RedirectToAction("ListView", "Blog")); } else { return(RedirectToAction("Index", "Home")); } }