public async Task <IResult <IReadOnlyCollection <string> > > HandleAsync(GetUserGamesNamesQuery query) { var validationResult = await IsValidAsync(query); if (validationResult.HasFailed()) { return(validationResult.Map <IReadOnlyCollection <string> >()); } var userId = query.UserId ?? query.CurrentUserId; var user = await _dataContext.Users .Include(x => x.Games) .ThenInclude(x => x.Game) .FirstAsync(x => x.Id == userId); return(user.Games .Select(x => x.Game.Name) .ToList() .ToSuccessfulResult()); }
private Task <IResult> IsValidAsync(GetUserGamesNamesQuery query) { _validator.ValidateUserIds(query.CurrentUserId, query.UserId); return(_validator.ValidateAsync()); }