/// <summary>
        /// Populate a GroupingDisplayObject
        /// </summary>
        /// <param name="dataElements"></param>
        /// <param name="colors"></param>
        /// <param name="filters"></param>
        /// <param name="cohorts"></param>
        /// <param name="students"></param>
        /// <param name="sections"></param>
        /// <returns></returns>
        private static GroupingDisplayObject GetGroupingDisplayObject(Task<IEnumerable<DataElement>> dataElements, Task<IEnumerable<Color>> colors, IEnumerable<Models.Filter> filters, Task<CohortDisplayObject[]> cohorts, Task<StudentDisplayObject[]> students, Task<SectionDisplayObject[]> sections)
        {
            //Construct a master object to for display purpose
            var data = new GroupingDisplayObject();
            data.cohorts = cohorts.Result;

            IEnumerable<StudentDisplayObject> studentDisplayObjects = students.Result;
            List<StudentDisplayObject> listOfStudents = studentDisplayObjects.ToList();
            listOfStudents.Sort();

            data.students = listOfStudents;
            data.sections = sections.Result;
            data.dataElements = dataElements.Result;
            data.colors = colors.Result;
            data.filters = filters;
            return data;
        }
        public async Task<ActionResult> Group()
        {
            var cs = new CohortService(Session["access_token"].ToString());
            var ss = new StudentService(Session["access_token"].ToString());

            var co = GetCohorts();
            var st = GetStudents();

            await Task.WhenAll(co, st);

            var cohorts = Task.WhenAll(from c in co.Result select CohortHelper.GetCohortDisplayObject(cs, c));
            var students = Task.WhenAll(from s in st.Result select StudentHelper.GetStudentDisplayObject(ss, s));

            await Task.WhenAll(cohorts, students);

            var data = new GroupingDisplayObject();
            data.cohorts = cohorts.Result;
            data.students = students.Result;
            data.filters = FilterHelper.InitializeFilters();

            return View(data);
        }
        /// <summary>
        /// Populate a GroupingDisplayObject
        /// </summary>
        /// <param name="dataElements"></param>
        /// <param name="colors"></param>
        /// <param name="filters"></param>
        /// <param name="cohorts"></param>
        /// <param name="students"></param>
        /// <param name="sections"></param>
        /// <returns></returns>
        private static GroupingDisplayObject GetGroupingDisplayObject(Task<IEnumerable<DataElement>> dataElements, Task<IEnumerable<Color>> colors, IEnumerable<Models.Filter> filters, Task<CohortDisplayObject[]> cohorts, Task<StudentDisplayObject[]> students, Task<SectionDisplayObject[]> sections)
        {
            //Construct a master object to for display purpose
            var data = new GroupingDisplayObject();
            
            //Remove cohorts that were not created by the grouping app by checking for the presence of a custom field.
            var valid_cohorts = new List<CohortDisplayObject>(cohorts.Result);
            foreach (CohortDisplayObject cohort in cohorts.Result)
            {
                if (cohort.custom == null)
                {
                    valid_cohorts.Remove(cohort);
                }
            }
            data.cohorts = valid_cohorts;


            IEnumerable<StudentDisplayObject> studentDisplayObjects = students.Result;
            List<StudentDisplayObject> listOfStudents = studentDisplayObjects.ToList();
            listOfStudents.Sort();

            data.students = listOfStudents;
            data.sections = sections.Result;
            data.dataElements = dataElements.Result;
            data.colors = colors.Result;
            data.filters = filters;
            return data;
        }