Ejemplo n.º 1
0
        public static JsonComment SaveComment(string[] vals)
        {
            WebUtils.CheckRightsForAdminCommentsPages(false);

            var    gId     = new Guid(vals[0]);
            string author  = vals[1];
            string email   = vals[2];
            string website = vals[3];
            string cont    = vals[4];

            foreach (Post p in Post.Posts.ToArray())
            {
                foreach (Comment c in p.Comments.ToArray())
                {
                    if (c.Id == gId)
                    {
                        c.Author  = author;
                        c.Email   = email;
                        c.Website = string.IsNullOrEmpty(website) ? null : new Uri(website);
                        c.Content = cont;

                        // need to mark post as "dirty"
                        p.DateModified = DateTime.Now;
                        p.Save();

                        return(JsonComments.GetComment(gId));
                    }
                }
            }

            return(new JsonComment());
        }
Ejemplo n.º 2
0
        public static JsonComment SaveComment(string id, string author, string email, string website, string cont)
        {
            // There really needs to be validation here so people aren't just posting willy-nilly
            // as anyone they want.

            if (!Security.IsAuthorizedTo(Rights.CreateComments))
            {
                throw new System.Security.SecurityException("Can not create comment");
            }


            var gId = new Guid(id);
            var jc  = new JsonComment();

            foreach (var p in Post.Posts.ToArray())
            {
                foreach (var c in p.Comments.Where(c => c.Id == gId).ToArray())
                {
                    c.Author  = author;
                    c.Email   = email;
                    c.Website = new Uri(website);
                    c.Content = cont;

                    // need to mark post as "dirty"
                    p.DateModified = DateTime.Now;
                    p.Save();

                    return(JsonComments.GetComment(gId));
                }
            }

            return(jc);
        }
Ejemplo n.º 3
0
        public static JsonComment GetComment(string id)
        {
            WebUtils.CheckRightsForAdminCommentsPages(false);

            return(JsonComments.GetComment(new Guid(id)));
        }