private async Task MapUserBetAndWinningSelection(int userId, IEnumerable <TournamentReponse> result) { // set user choice. foreach (var tournament in result) { var bets = await _tournamentService.GetBetAsync(userId, tournament.Id); foreach (var winnable in tournament.Winnables) { winnable.TypeOfReward = "freebets"; } foreach (var market in tournament.Markets) { market.ChosenSelectionId = bets.FirstOrDefault(s => s.Market.Id == market.Id)?.Selection?.Id; } } }
public async Task <IActionResult> SeeResult(int?userId, int?tournamentId) { if (userId == null || tournamentId == null) { return(NotFound()); } var tournament = await _tournamentService.GetAsync(tournamentId.Value); if (tournament == null) { return(NotFound()); } var resultingTournamentViewModel = _mapper.Map <ResultingTournamentViewModel>(tournament); var bets = await _tournamentService.GetBetAsync(userId.Value, tournament.Id); foreach (var market in resultingTournamentViewModel.Markets) { market.ChosenSelectionId = bets.FirstOrDefault(s => s.Market.Id == market.Id)?.Selection?.Id; } return(View(_mapper.Map <ResultingTournamentViewModel>(resultingTournamentViewModel))); }