예제 #1
0
        public async Task <Result <VoteMonitoringStats> > GetVoteMonitoringStats(string electionId)
        {
            var result = await _resultsRepository.Get(electionId, Consts.VOTE_MONITORING_KEY, FileType.VoteMonitoring.ConvertEnumToString());

            if (result.IsSuccess)
            {
                var voteMonitoringStats = JsonConvert.DeserializeObject <VoteMonitoringStats>(result.Value.StatisticsJson);
                return(Result.Ok(voteMonitoringStats));
            }
            return(Result.Failure <VoteMonitoringStats>("Failed to retrieve vote monitoring stats"));
        }
        public async Task <IActionResult> GetAsync(string id)
        {
            try
            {
                var result = await _resultsRepository.Get(id);

                _logger.LogInformation($"Result with id: {id} found.");
                return(result);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Error: {e.Message}");
                var responce = new Dictionary <string, string> {
                    { "error", e.Message }
                };
                return(new JsonResult(responce));
            }
        }