Esempio n. 1
0
        public ActionResult AddPost(string title, string content, string tags)
        {
            var success = false;
            var html = "";
            if (Request.IsAuthenticated)
            {
                var jss = new JavaScriptSerializer();
                var postTags = jss.Deserialize<List<string>>(tags);
                postTags = postTags.Select(x => x.Trim()).ToList();

                var post = new PostModel(User);
                var newpost = post.AddPost(title, content, postTags);
                html = RenderPartialToString("~/Views/Blog/BlogPost.cshtml", newpost);

                success = true;
            }

            return new JsonResult
            {
                Data = new {
                    success, html
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }
Esempio n. 2
0
        public ActionResult EditPost(string title, string content, int postid)
        {
            var post = new PostModel(User);
            var updatedPost = post.EditPost(title, content, postid);

            return new JsonResult
            {
                Data = new {
                    success = true,
                    html = RenderPartialToString("~/Views/Blog/BlogPost.cshtml", updatedPost)
                }
            };
        }
Esempio n. 3
0
        public ActionResult RemovePost(int? postid)
        {
            var success = false;
            if (postid.HasValue)
            {
                var post = new PostModel(User);
                success = post.RemovePost(postid.Value);
            }

            return new JsonResult
            {
                Data = new {
                    success
                }
            };
        }