예제 #1
0
        public void UpdateTagComment(string userLogin, long commentId, List <String> tags)
        {
            Comment comment = CommentDao.Find(commentId);

            comment.Tags.Clear();

            foreach (var tag in tags)
            {
                String tagLower = tag.ToLower();
                if (!TagDao.Exists(tagLower))
                {
                    Tag newTag = new Tag
                    {
                        tagName = tagLower
                    };
                    newTag.Comment.Add(comment);
                    TagDao.Create(newTag);
                    comment.Tags.Add(newTag);
                }
                else
                {
                    Tag tagInDatabase = TagDao.Find(tagLower);
                    comment.Tags.Add(tagInDatabase);
                    tagInDatabase.Comment.Add(comment);
                }
            }
        }
예제 #2
0
        /// <exception cref="InstanceNotFoundException"/>
        public void UpdateComment(long commentId, string commentBody)
        {
            Comment comment = CommentDao.Find(commentId);

            comment.comment1 = commentBody;

            CommentDao.Update(comment);
        }
예제 #3
0
        public DTOComment getComment(long commentId)
        {
            Comment comment;

            comment = CommentDao.Find(commentId);

            //////////FALTA DEVOLVER LOS TAGS DEL COMENTARIO en el DTO
            return(new DTOComment(commentId, comment.UserProfile.loginName, comment.eventId, comment.comment_description, comment.publishDate, null));
        }
예제 #4
0
        public void UpdateComment(long commentId, string comment_text)
        {
            Comment comment;

            comment = CommentDao.Find(commentId);
            comment.comment_description = comment_text;

            //UpdateTagComment(commentId,tags);
            CommentDao.Update(comment);
        }
예제 #5
0
        public void DeleteComment(long commentId, long userId)
        {
            Comment c = CommentDao.Find(commentId);

            if (c.UserProfile.usrId == userId)
            {
                CommentDao.Remove(commentId); //Remove no funciona
            }
            else
            {
                throw new Exception();
            }
        }
예제 #6
0
        public Comment EditComment(long commentId, long userId, string newComment)
        {
            Comment c = CommentDao.Find(commentId);

            if (c.UserProfile.usrId == userId)
            {
                c.content = newComment;
                CommentDao.Update(c);
            }
            else
            {
                throw new Exception();
            }
            return(c);
        }
예제 #7
0
        public ICollection <LabelDto> GetCommentLabels(long commentId)
        {
            Comment comment = CommentDao.Find(commentId);
            ICollection <LabelDto> labelDtos = new List <LabelDto>();

            foreach (Label l in comment.Labels)
            {
                ICollection <CommentDto> commentsDtos = new List <CommentDto>();
                foreach (Comment c in l.Comments)
                {
                    commentsDtos.Add(new CommentDto(c, c.Event.eventId));
                }
                labelDtos.Add(new LabelDto(l.labelId, l.name, l.commentsNum, commentsDtos));
            }
            return(labelDtos);
        }
예제 #8
0
        public Comment AddLabel(long commentId, ICollection <Label> labels)
        {
            Comment c = CommentDao.Find(commentId);

            foreach (Label l in labels)
            {
                if (!c.Labels.Contains(l))
                {
                    c.Labels.Add(l);
                    l.commentsNum++;
                    LabelDao.Update(l);
                }
            }
            CommentDao.Update(c);
            return(c);
        }
예제 #9
0
        /// <exception cref="InstanceNotFoundException"/>
        public void UpdateComment(long commentId, string commentBody, List <long> newTags)
        {
            Comment comment = CommentDao.Find(commentId);

            ICollection <Tag> tags = new List <Tag>();

            comment.comment1 = commentBody;
            comment.Tags.Clear();
            foreach (var tagId in newTags)
            {
                tags.Add(TagDao.Find(tagId));
            }

            comment.Tags = tags;

            CommentDao.Update(comment);
        }
예제 #10
0
        public Comment RemoveLabel(long commentId, ICollection <Label> labels)
        {
            Comment comment = CommentDao.Find(commentId);

            foreach (Label l in labels)
            {
                if (comment.Labels.Contains(l))
                {
                    comment.Labels.Remove(l);
                    l.commentsNum--;
                    l.Comments.Remove(comment);
                    LabelDao.Update(l);
                }
            }
            CommentDao.Update(comment);
            return(comment);
        }
예제 #11
0
        /// <exception cref="InstanceNotFoundException"/>
        public void DeleteComment(long commentId)
        {
            var comment = CommentDao.Find(commentId);

            CommentDao.Remove(comment.commentId);
        }
예제 #12
0
 public Comment FindCommentById(long commentId)
 {
     return(CommentDao.Find(commentId));
 }