Ejemplo n.º 1
0
        public List <Comment> GetComments(long imageId)
        {
            var comments = DbManager
                           .ExecuteList(Query("photo_comment").Select(Mappers.CommentColumns).Where("Image", imageId))
                           .ConvertAll(r => Mappers.ToComment(r));

            var timestamp = ASC.Core.Tenants.TenantUtil.DateTimeFromUtc(DbManager.ExecuteScalar <DateTime>(
                                                                            Query("photo_imageview")
                                                                            .Select("Timestamp")
                                                                            .Where("User", SecurityContext.CurrentAccount.ID.ToString())
                                                                            .Where("Image", imageId)));

            comments.ForEach(c =>
            {
                if (c.ParentId != 0)
                {
                    var parent = comments.Find(c2 => c2.Id == c.ParentId);
                    if (parent != null)
                    {
                        parent.Comments.Add(c);
                    }
                }
                c.IsRead = c.Timestamp < timestamp;
            });
            comments.RemoveAll(c => c.ParentId != 0);

            return(comments);
        }
Ejemplo n.º 2
0
        public Comment GetComment(long id)
        {
            var comments = DbManager
                           .ExecuteList(Query("photo_comment").Select(Mappers.CommentColumns).Where("Id", id))
                           .ConvertAll(r => Mappers.ToComment(r));

            return(0 < comments.Count ? comments[0] : null);
        }
Ejemplo n.º 3
0
 public static CommentNews ToCommentNews(object[] row)
 {
     return(new CommentNews
     {
         Comment = Mappers.ToComment(row),
         Image = new AlbumItem()
         {
             Name = Convert.ToString(row[7]),
             Location = Convert.ToString(row[8]),
             UserID = Convert.ToString(row[9]),
             AlbumId = Convert.ToInt64(row[10])
         }
     });
 }