Beispiel #1
0
        public List <Interview> ReadSurveydata(Guid id, int?start, int?numberOfRecords)
        {
            if (start == null && numberOfRecords != null || start != null && numberOfRecords == null)
            {
                throw new ArgumentException("Invalid paging arguments");
            }

            List <Interview> allInterviews;

            // ReSharper disable once ConvertSwitchStatementToSwitchExpression
            switch (id.ToString())
            {
            case SP5201Id:
                allInterviews = SP5201.LoadAllInterviews();
                break;

            case PR9012Id:
                allInterviews = PR9012_HOUSEHOLD.LoadAllInterviews();
                break;

            default:
                throw new ArgumentException($"Unrecognised survey id {id}");
            }

            if (start > allInterviews.Count)
            {
                throw new ArgumentException($"Invalid paging arguments");
            }

            return(allInterviews
                   .Skip((start ?? 1) - 1) //-1 to convert 1-based start argument into zero based skip argument
                   .Take(numberOfRecords ?? allInterviews.Count)
                   .ToList());
        }
Beispiel #2
0
        public SurveyMetadata ReadSurveyMetadata(Guid id)
        {
            switch (id.ToString())
            {
            case SP5201Id:
                return(SP5201.ReadMetadata());

            case PR9012Id:
                return(PR9012_HOUSEHOLD.ReadMetadata());

            default:
                throw new ArgumentException($"Unrecognised survey id {id}");
            }
        }