Esempio n. 1
0
        public override async Task <ListResponse> Paginate(PaginateRequest request, ServerCallContext context)
        {
            var from = request.From > 0
                ? request.From as long?
                : null;

            var list = await _mediator.Send(new PaginatedMessagesQuery(from));

            var response = new ListResponse();

            response.Messages.Add(list.Select(ToResponse));
            return(response);
        }
Esempio n. 2
0
        public override async Task <ListResponse> Paginate(PaginateRequest request, ServerCallContext context)
        {
            using (var scope = _scopeFactory.CreateScope())
            {
                var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();
                var from     = request.From > 0
                    ? request.From as long?
                    : null;

                var list = await mediator.Send(new PaginatedMessagesQuery(from));

                var response = new ListResponse();
                response.Messages.Add(list.Select(ToResponse));
                return(response);
            }
        }