Example #1
0
        public ActionResult AddComment(ViewPostModel vpm)
        {
            if (User.Identity.IsAuthenticated)
            {
                vpm.Comment.Email = "RegisteredUser@" + User.Identity.Name + ".com";
                vpm.Comment.User = User.Identity.Name;
            }
            vpm.Comment.Date = DateTime.Now;

            if (ModelState.IsValid)
            {
                repository.AddComment(vpm.Comment);
                repository.SaveChanges();
            }
            return RedirectToAction("FullPost", new { vpm.Comment.PostId });
        }
Example #2
0
        public ActionResult FullPost(int postId)
        {
            ViewPostModel vp = new ViewPostModel();
            vp.Post = repository.FindPostById(postId);
            if (vp.Post == null)
            {
                return HttpNotFound();
            }
            ViewBag.PostUser = false;
            if (User.Identity.Name == vp.Post.PostUser)
            {
                ViewBag.PostUser = true;
            }

            return View(vp);
        }