예제 #1
0
        public List <PhotoComment> VisitPhotoGetComments(GetComments method, JToken data)
        {
            var result     = new List <PhotoComment>();
            var commentors = new List <VkPrincipal>();

            foreach (var item in data["response"]["profiles"])
            {
                var profile = new User();
                profile.Accept(this.ObjectParser, item);
                commentors.Add(profile);
            }
            foreach (var item in data["response"]["groups"])
            {
                var group = new Group();
                group.Accept(this.ObjectParser, item);
                commentors.Add(group);
            }
            foreach (var item in data["response"]["items"])
            {
                var comment = new PhotoComment();
                comment.Accept(this.ObjectParser, item);
                comment.Creator = commentors.SingleOrDefault(x => x.Id == comment.FromId);
                result.Add(comment);
            }
            return(result);
        }
예제 #2
0
        public async Task <IEnumerable <CommentDto> > HandleAsync(GetComments query)
        {
            var documents = _commentRepository.Collection.AsQueryable();

            if (query.ProjectId == null && query.IssueId == null)
            {
                return(Enumerable.Empty <CommentDto>());
            }

            var issue = await _issueRepository.GetAsync(query.IssueId);

            if (query.IssueId != null && issue == null)
            {
                return(Enumerable.Empty <CommentDto>());
            }

            var project = await _projectRepository.GetAsync(query.ProjectId);

            if (query.ProjectId != null && project == null)
            {
                return(Enumerable.Empty <CommentDto>());
            }

            var filter = new Func <CommentDocument, bool>(p =>
                                                          (query.ProjectId == null || p.ProjectId == query.ProjectId) &&
                                                          (query.IssueId == null || p.IssueId == query.IssueId));

            var comments = documents.Where(filter).ToList();

            return(comments.Select(p => p.AsDto(_appContext.Identity)));
        }
예제 #3
0
        public async Task <IActionResult> GetComments(int groupId, int postId)
        {
            var command = new GetComments {
                GroupId = groupId, PostId = postId
            };

            return(Ok(await _mediator.Send(command)));
        }
예제 #4
0
        public Task <PagedResult <Comment> > Handle(GetComments request, CancellationToken cancellationToken)
        {
            if (request.Page < 1)
            {
                request.Page = 1;
            }
            var comments = _commentRepository.GetList(x => x.PostId.Equals(request.PostId), request.Page, 20);

            return(Task.FromResult(comments));
        }
예제 #5
0
        private void AffectURI(Uri baseAddress)
        {
            _baseAddress = baseAddress.AbsoluteUri;
            _builds      = BaseObjectApi <Builds> .CreateObject(this);

            _TestResults = BaseObjectApi <Test> .CreateObject(this);

            _VersionControl = BaseObjectApi <Versioncontrol> .CreateObject(this);

            _wit = BaseObjectApi <Wit> .CreateObject(this);

            _getComments = BaseObjectApi <GetComments> .CreateObject(this);
        }
예제 #6
0
        public static List <PhotoComment> GetComments(IExecuteSystem es, String owner, String photo,
                                                      Boolean?needLikes = null, Int32?offset = null, Int32?count = null, String sort = null,
                                                      Boolean?extended  = null)
        {
            var method = new GetComments
            {
                OwnerId   = owner,
                PhotoId   = photo,
                NeedLikes = needLikes,
                Offset    = offset,
                Count     = count,
                Sort      = sort,
                Extended  = extended
            };

            return(es.Execute(method));
        }
예제 #7
0
        public async Task <object> Get(GetComments request)
        {
            try
            {
                var comments = await _commentsRepository.GetCommentsAsync(request.MovieId);

                return(new GetCommentsResponse
                {
                    Comments = comments
                });
            }
            catch (Exception ex)
            {
                return(new GetCommentsResponse
                {
                    Comments = null,
                    ResponseStatus = GetResponseStatus(ex)
                });
            }
        }
예제 #8
0
 public List <PhotoComment> VisitPhotoGetComments(GetComments method, T data)
 {
     return(this.photoVisitor.VisitPhotoGetComments(method, data));
 }