public async Task <List <Enrollment> > GetEnrollments(EnrollmentInputParameters inputParameters, CancellationToken cancellationToken) { var apiEnrollments = new List <Enrollment>(); var dataEnrollments = new List <DataModel.Enrollment>(); if (!inputParameters.StudentId.HasValue && string.IsNullOrWhiteSpace(inputParameters.Period)) { dataEnrollments = await _context.GetEnrollments(cancellationToken); } else if (inputParameters.StudentId.HasValue && string.IsNullOrWhiteSpace(inputParameters.Period)) { dataEnrollments = await _context.GetEnrollmentsByStudentId(inputParameters.StudentId.Value, cancellationToken); } else if (inputParameters.StudentId.HasValue && !string.IsNullOrWhiteSpace(inputParameters.Period)) { dataEnrollments = await _context.GetEnrollmentsByStudentAndPeriod(inputParameters.StudentId.Value, inputParameters.Period, cancellationToken); } else { dataEnrollments = await _context.GetEnrollmentsByPeriod(inputParameters.Period, cancellationToken); } apiEnrollments = ArrangeAsList(dataEnrollments); return(apiEnrollments); }