public async Task <IActionResult> Get(string moniker) { try { var talks = _mapper.Map <IEnumerable <TalkViewModel> >(await _repo.GetTalksAsync(moniker)); // Update Vote Counts var counts = await _repo.GetTalkCountsAsync(moniker); foreach (var t in talks) { var result = counts.Where(c => c.Item1.Id == t.Id).FirstOrDefault(); if (result != null) { t.Votes = result.Item2; } } return(Ok(talks)); } catch (Exception ex) { _logger.LogError("Failed to get talks: {0}", ex); } return(BadRequest("Couldn't load talks.")); }