public async Task <ActionResult <List <PartyList> > > GetCandidatesForBallot([FromQuery] ElectionResultsQuery query, int ballotId) { try { query.BallotId = ballotId; if (query.LocalityId == 0) { query.LocalityId = null; } if (query.CountyId == 0) { query.CountyId = null; } if (query.Round == 0) { query.Round = null; } var result = await _appCache.GetOrAddAsync( query.GetCacheKey(), () => _resultsAggregator.GetBallotCandidates(query), DateTimeOffset.Now.AddMinutes(query.GetCacheDurationInMinutes())); return(result.Value); } catch (Exception e) { _appCache.Remove(query.GetCacheKey()); Log.LogError(e, "Exception encountered while retrieving voter turnout stats"); return(StatusCode(500, e.StackTrace)); } }
//[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)] public async Task <ActionResult <ElectionResponse> > GetBallot([FromQuery] ElectionResultsQuery query) { try { if (query.LocalityId == 0) { query.LocalityId = null; } if (query.CountyId == 0) { query.CountyId = null; } if (query.Round == 0) { query.Round = null; } var result = await _appCache.GetOrAddAsync( query.GetCacheKey(), () => _resultsAggregator.GetBallotResults(query), DateTimeOffset.Now.AddMinutes(query.GetCacheDurationInMinutes())); var newsFeed = await _resultsAggregator.GetNewsFeed(query, result.Value.Meta.ElectionId); result.Value.ElectionNews = newsFeed; return(result.Value); } catch (Exception e) { _appCache.Remove(query.GetCacheKey()); Log.LogError(e, "Exception encountered while retrieving voter turnout stats"); return(StatusCode(500, e.StackTrace)); } }