public ActionResult CreatePost(int threadId, string body) { var nPost = new ForumPost { Body = body.Replace("\n", "[br]"), ForumThreadId = threadId, OwnerId = User.Identity.GetUserId(), PostedDate = DateTime.Now, IsEdited = false }; db.ForumPosts.Add(nPost); db.SaveChanges(); var eThread = db.ForumThreads.Find(nPost.ForumThreadId); eThread.UpdatedDate = DateTime.Now; db.SaveChanges(); return RedirectToAction("Thread", new {id = threadId}); }
public ActionResult GrabNewPreview(string body) { var nPost = new ForumPost { Body = body, PostedDate = DateTime.Now, Owner = db.Users.Find(User.Identity.GetUserId()), IsEdited = false }; return PartialView("_Preview", nPost); }
public ActionResult PostThread(string title, string body, int sectionId) { var nThread = new ForumThread() { Title = title, ForumSectionId = sectionId, IsLocked = false, IsSticky = false, UpdatedDate = DateTime.Now }; db.ForumThreads.Add(nThread); db.SaveChanges(); var nPost = new ForumPost { Body = body.Replace("\n", "[br]"), ForumThreadId = nThread.ForumThreadId, OwnerId = User.Identity.GetUserId(), PostedDate = DateTime.Now }; db.ForumPosts.Add(nPost); db.SaveChanges(); return RedirectToAction("Thread", new {id = nThread.ForumThreadId}); }