public async Task <ActionResult <TodoReadDTO> > GetTodoById([FromRoute] int id) { var request = new GetSpecifiedTodoQuery(User.Identity?.Name, id); var response = await _mediator.Send(request); return(response.Match <ActionResult <TodoReadDTO> >( todoReadDto => Ok(todoReadDto), notFound => NotFound() )); }
public async Task <OneOf <TodoReadDTO, NotFound> > Handle(GetSpecifiedTodoQuery request, CancellationToken cancellationToken) { var userTodo = await _todosRepository.ReadQuery() .Where(todo => todo.Id == request.Id && todo.UserLogin == request.UserLogin) .Include(todo => todo.Labels) .FirstOrDefaultAsync(cancellationToken); if (userTodo == null) { return(new NotFound()); } return(userTodo.ToReadDTO()); }