public IActionResult GetRelationStatistics(GetRelationStatisticsRequest request)
        {
            GetRelationStatisticsResponse result = new GetRelationStatisticsResponse();

            if (request != null && request.Filter != null)
            {
                HandleException(() =>
                {
                    var data = new RelationStatisticsData();
                    var totalRelationStatsRepository          = DALRepositories.GetTotalRelationStatisticsRepository();
                    var statementRelationStatisticsRepository = DALRepositories.GetNormalizedStatementRelationStatisticsRepository();
                    data.TotalRelationStatistics            = totalRelationStatsRepository.GetAllForRelation(request.RelationID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.RelationSummaryStatementStatistics = statementRelationStatisticsRepository.GetRelationSummaryStatementStatistics(request.RelationID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    result.Data      = data;
                    result.IsSuccess = result.Data != null;
                }, ex => result.ErrorMessage = ex.Message);
            }
            return(Json(result));
        }
        public IActionResult GetStatementStatistics(GetStatementStatisticsRequest request)
        {
            GetStatementStatisticsResponse result = new GetStatementStatisticsResponse();

            if (request != null && request.Filter != null)
            {
                HandleException(() =>
                {
                    var data = new StatementStatisticsData();
                    var totalStatsRepository         = DALRepositories.GetNormalizedStatementStatisticsRepository();
                    var relationStatsRepository      = DALRepositories.GetNormalizedStatementRelationStatisticsRepository();
                    var indexStatsRepository         = DALRepositories.GetNormalizedStatementIndexStatisticsRepository();
                    data.StatementTimeline           = totalStatsRepository.GetTimelineForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.StatementRelationStatistics = relationStatsRepository.GetAllForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.StatementIndexStatistics    = indexStatsRepository.GetAllForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.SlowestRepresentatives      = totalStatsRepository.GetSlowestForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo, 10).ToList();
                    result.Data      = data;
                    result.IsSuccess = result.Data != null;
                }, ex => result.ErrorMessage = ex.Message);
            }
            return(Json(result));
        }