Ejemplo n.º 1
0
        public async Task <List <RepoListDTO> > Handle(GetAllReposByUserQuery request, CancellationToken cancellationToken)
        {
            var reposList = await _repoRepository.GetList(request.UserId);

            if (reposList == null)
            {
                throw new Exception("No repository found. Failed to get list.");
            }

            var repoDTOList = _mapper.Map <List <Repository>, List <RepoListDTO> >(reposList);

            return(repoDTOList);
        }
Ejemplo n.º 2
0
        public async Task <UserDetailsDTO> Handle(GetUserDetailsQuery request, CancellationToken cancellationToken)
        {
            var user = await _userRepository.GetById(request.UserId);

            if (user == null)
            {
                throw new Exception("User not found. Failed to get details.");
            }

            var userDetailsDTO = _mapper.Map <User, UserDetailsDTO>(user);

            if (user.Repositories != null)
            {
                userDetailsDTO.Repositories = await _repoRepository.GetList(user.Repositories);
            }

            return(userDetailsDTO);
        }