/// <summary> /// Get SchoolsViewModel /// </summary> public async Task <SchoolsViewModel> GetSchoolsViewModelAsync(UserContext userContext) { EducationUser currentUser = await educationServiceClient.GetJoinableUserAsync(); //previous call does not return Schools correctly currentUser.Schools = await educationServiceClient.GetMySchoolsAsync(); var schools = (await educationServiceClient.GetSchoolsAsync()) .OrderBy(i => i.Name) .ToArray(); for (var i = 0; i < schools.Count(); i++) { if (schools[i].Address != null && string.IsNullOrEmpty(schools[i].Address.Street) && string.IsNullOrEmpty(schools[i].Address.PostalCode)) { schools[i].Address.Street = "-"; } } var mySchools = currentUser.Schools.ToArray(); var myFirstSchool = mySchools.FirstOrDefault(); // Specific grade for students will be coming in later releases of the API. var grade = myFirstSchool?.EducationGrade; var sortedSchools = mySchools.Count() > 0? (schools.Where(c => c.Id == mySchools.First().Id) .Union(schools.Where(c => c.Id != mySchools.First().Id).ToList())):schools; return(new SchoolsViewModel(sortedSchools) { IsStudent = userContext.IsStudent, UserId = currentUser.ExternalId ?? "", EducationGrade = grade, UserDisplayName = currentUser.DisplayName, MySchoolId = myFirstSchool?.ExternalId ?? "" }); }