Exemplo n.º 1
0
        public async Task <QueryResult <IEnumerable <EventListItemDto> > > Handle(GetEventsMessage request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"{nameof(GetEventsHandler)} - Handler - Start");

            _logger.LogInformation("generating specification from request");
            var specification = new EventSpecification(request);

            _logger.LogInformation("retrieving result from manager");
            var result = await _manager.GetAsync(specification);

            _logger.LogInformation($"mapping result to dto");
            var data = _mapper.Map <IEnumerable <EventEntity>, IEnumerable <EventListItemDto> >(result);

            _logger.LogInformation($"creating {nameof(QueryResult)} from mapped data");
            var queryResult = QueryResult <IEnumerable <EventListItemDto> > .New(data);

            _logger.LogInformation($"{nameof(GetEventsHandler)} - Handler - End");

            return(queryResult);
        }
        public async Task <IActionResult> GetEventsAsync([FromQuery] GetEventsMessage message)
        {
            var result = await _mediator.Send(message);

            return(Ok(result));
        }