public async Task <IActionResult> GetComments([FromQuery] GetCommentsRequest req) { Logger.LogInformation($"Get product comments with filter: ProductCode={req?.ProductCode}"); int?productId = await Service.GetId(req.ProductCode).ConfigureAwait(false); if (!productId.HasValue) { return(NotFound($"ProductCode={req?.ProductCode}")); } var comments = await Service.GetComments(productId).ConfigureAwait(false); var result = new GetCommentResponse(); if (comments != null) { result.Comments = new List <GetCommentResponse.Comment>(); foreach (var comment in comments) { result.Comments.Add(new GetCommentResponse.Comment { PosterName = comment.PosterName, ProductName = comment.ProductName, Rating = comment.Rating, Description = comment.Description }); } } return(Ok(result)); }
private void onCommentRepliesRequested(DrawableComment drawableComment, int page) { var request = new GetCommentsRequest(CommentableId.Value, Type.Value, Sort.Value, page, drawableComment.Comment.Id); request.Success += response => Schedule(() => AppendComments(response)); api.PerformAsync(request); }
public async Task <Listing> GetCommentsAsync(GetCommentsRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var listings = await Api.GetMultiListingAsync(string.Format(UrlConstants.LinkCommentsUrl, Subreddit, Id), request, cancellationToken); return(listings.Last()); }
private void getComments() { request?.Cancel(); loadCancellation?.Cancel(); request = new GetCommentsRequest(type, id, Sort.Value, currentPage++); request.Success += onSuccess; api.Queue(request); }
public override async Task <GetCommentsReply> GetComments(GetCommentsRequest request, ServerCallContext context) { var commentList = await _commentService.GetCommentsAsync(); return(new GetCommentsReply { CommentList = { _mapper.Map <IEnumerable <CommentMessage> >(commentList) } }); }
public async Task <IEnumerable <GetCommentsResponse> > Handle(GetCommentsRequest request, CancellationToken cancellationToken) { var comments = await _dbContext.Comments .Include(comment => comment.User) .Include(comment => comment.Reports) .ThenInclude(report => report.User) .ToListAsync(); return(_mapper.Map <IEnumerable <GetCommentsResponse> >(comments)); }
public async Task <GetCommentsResponse> GetComments([FromQuery] GetCommentsRequest request) { var result = await _commentService.GetCommentsAsync(request); return(new GetCommentsResponse() { Items = result.Items, TotalCount = result.TotalCount, MoreItemsExists = result.MoreItemsExists }); }
public void TestGetComments() { var localName = "test_multi_pages.docx"; var remoteName = "TestGetComments.docx"; var fullName = Path.Combine(this.dataFolder, remoteName); this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName)); var request = new GetCommentsRequest(remoteName, this.dataFolder); var actual = this.WordsApi.GetComments(request); Assert.AreEqual(200, actual.Code); }
private void getComments() { if (id.Value <= 0) { return; } request?.Cancel(); loadCancellation?.Cancel(); request = new GetCommentsRequest(id.Value, type.Value, Sort.Value, currentPage++, 0); request.Success += onSuccess; api.PerformAsync(request); }
private void getComments() { if (id.Value <= 0) { return; } request?.Cancel(); loadCancellation?.Cancel(); scheduledCommentsLoad?.Cancel(); request = new GetCommentsRequest(id.Value, type.Value, Sort.Value, currentPage++, 0); request.Success += res => scheduledCommentsLoad = Schedule(() => OnSuccess(res)); api.PerformAsync(request); }
public List <MessageThreads> GetComments(GetCommentsRequest commentsRequest, ICommentsDataBaseSettings settings) { ConnectToDB(settings); QueryStringHelper helper = new QueryStringHelper(); String query = helper.GetCommentsQueryString(commentsRequest); if (commentsRequest.IsSortByLatest) { return(_mongoDatabase.GetCollection <MessageThreads>("messagethreads").Find(query).Sort("{createdDate:-1}").Limit(10).ToList <MessageThreads>()); } else { return(_mongoDatabase.GetCollection <MessageThreads>("messagethreads").Find(query).Sort("{createdDate:1}").Limit(10).ToList <MessageThreads>()); } }
public string GetCommentsQueryString(GetCommentsRequest commentsRequest) { String queryString = String.Format(MongoDbQuery.RootId, commentsRequest.RootID) + String.Format(MongoDbQuery.PostID, commentsRequest.PostID); if (commentsRequest.IsDateRange && commentsRequest.StartDate != null && commentsRequest.EndDate != null && commentsRequest.StartDate.Length > 0 && commentsRequest.EndDate.Length > 0) { queryString += GetDateRangeQueryString(commentsRequest.StartDate, commentsRequest.EndDate); } if (commentsRequest.IsPagination && commentsRequest.LastCommentID != null) { queryString += String.Format(MongoDbQuery.Pagination, commentsRequest.LastCommentID); } if (commentsRequest.IsKeywords && commentsRequest.Keywords != null && commentsRequest.Keywords.Count > 0) { queryString += GetKeywordQueryString(commentsRequest.Keywords); } return(String.Format(MongoDbQuery.AndQuery, queryString)); }
public void TestGetComments() { string remoteFileName = "TestGetComments.docx"; this.UploadFileToStorage( remoteDataFolder + "/" + remoteFileName, null, null, File.ReadAllBytes(LocalTestDataFolder + localFile) ); var request = new GetCommentsRequest( name: remoteFileName, folder: remoteDataFolder ); var actual = this.WordsApi.GetComments(request); Assert.NotNull(actual.Comments); Assert.NotNull(actual.Comments.CommentList); Assert.AreEqual(1, actual.Comments.CommentList.Count); Assert.AreEqual("Comment 1" + "\r\n\r\n", actual.Comments.CommentList[0].Text); }
public Task <Listing> GetCommentsAsync(GetCommentsRequest request, CancellationToken cancellationToken = default(CancellationToken)) { return(Api.GetListingAsync(string.Format(UrlConstants.CommentsUrl, Name), request, cancellationToken)); }
public List <MessageThreads> GetComments(GetCommentsRequest commentsRequest) { return(_commentService.GetComments(commentsRequest, _commentsDataBaseSettings)); }
public async Task <IActionResult> GetComments([FromQuery] GetCommentsRequest request) => await Mediator .Send(new GetDefaultQuery <CommentResponse>(request, ApiRoutes.Comments.Get)) .ToOkResult();
public Task StartAsync(CancellationToken cancellationToken) { var request = new GetCommentsRequest(_options); return(_requestAggreg.HandleAsync(request)); }