// GET: Posts/Details/5
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var postModel = _postManager.Find(id);

            return(View(postModel));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Post post = postManager.Find(x => x.Id == id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryId = new SelectList(CacheHelper.GetCategoriesFromCache(), "Id", "Title", post.CategoryId);
            return(View(post));
        }
        public ActionResult Create(Comment comment, int?noteid)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedName");

            if (ModelState.IsValid)
            {
                if (noteid == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                Post note = postManager.Find(x => x.Id == noteid);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }

                comment.Post  = note;
                comment.Owner = CurrentSession.User;

                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }