Ejemplo n.º 1
0
        private static JsonComment CreateJsonCommentFromComment(Comment c)
        {
            var jc = new JsonComment
            {
                Id           = c.Id,
                Email        = c.Email,
                Author       = c.Author,
                Title        = c.Title,
                Teaser       = c.Teaser,
                Website      = c.Website == null ? "" : c.Website.ToString(),
                AuthorAvatar = c.Avatar,
                Content      = c.Content,
                Ip           = c.IP,
                Date         = c.DateCreated.ToString("dd MMM yyyy"),
                Time         = c.DateCreated.ToString("t")
            };

            return(jc);
        }
Ejemplo n.º 2
0
 private static JsonComment CreateJsonCommentFromComment(Comment c)
 {
     var jc = new JsonComment
         {
             Id = c.Id,
             Email = c.Email,
             Author = c.Author,
             Title = c.Title,
             Teaser = c.Teaser,
             Website = c.Website == null ? "" : c.Website.ToString(),
             AuthorAvatar = c.Avatar,
             Content = c.Content,
             Ip = c.IP,
             Date = c.DateCreated.ToString("dd MMM yyyy"),
             Time = c.DateCreated.ToString("t")
         };
     return jc;
 }
Ejemplo n.º 3
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;
        }