public async Task <IActionResult> GetPubBoardGames(string id, [FromQuery] BoardGameQuery query) { try { var specification = _boardGameSpeczilla.GetSpecification(query, id); var result = await _boardGameService.GetPaginationResultAsync(specification); return(result.HasValue ? OkJson(result.Value.ToResponse()) : BadRequest()); } catch (Exception ex) { _logger.LogError(ex, "Error while getting board games from pub! " + $"PubId: {id}"); return(InternalServerErrorJson(ex)); } }
public async Task <IActionResult> Get([FromQuery] BoardGameQuery query) { try { var specification = _boardGameSpeczilla.GetSpecification(query); var result = await _boardGameService.GetPaginationResultAsync(specification); if (!result.HasValue) { return(NotFound()); } var responseResult = result.Value.ToResponse(); if (!string.IsNullOrWhiteSpace(UserEmail)) { var likedBoardGames = _hexadoUserService.GetLikedBoardGames(UserEmail); if (likedBoardGames.HasValue) { foreach (var likedBoardGame in likedBoardGames.Value) { var boardGame = responseResult.Results .SingleMaybe(rr => rr.Id == likedBoardGame.Id); if (boardGame.HasValue) { boardGame.Value.IsLikedByUser = true; } } } } return(OkJson(responseResult)); } catch (Exception ex) { _logger.LogError(ex, "Error while retrieving board games!"); return(InternalServerErrorJson(ex)); } }