예제 #1
0
        public async Task <ActionResult <IEnumerable <LabelReadDTO> > > GetAllLabels()
        {
            var request  = new GetAllLabelsQuery(User.Identity?.Name);
            var response = await _mediator.Send(request);

            return(response.Any() ? Ok(response) : NoContent());
        }
예제 #2
0
        public async Task <IEnumerable <LabelReadDTO> > Handle(GetAllLabelsQuery request, CancellationToken cancellationToken)
        {
            var labels = await _labelsRepository.ReadQuery()
                         .Where(label => label.UserLogin == request.UserLogin)
                         .ToListAsync(cancellationToken);

            if (!labels.Any())
            {
                return(Enumerable.Empty <LabelReadDTO>());
            }

            return(labels.Select(label => label.ToReadDTO()));
        }