/// <summary> /// Get SectionDetailsViewModel of the specified section /// </summary> public async Task <SectionDetailsViewModel> GetSectionDetailsViewModelAsync(string schoolId, string classId, IGroupRequestBuilder group) { var school = await educationServiceClient.GetSchoolAsync(schoolId); var @class = await educationServiceClient.GetClassAsync(classId); @class.Teachers = @class.Members.Where(c => c.PrimaryRole == EducationRole.Teacher).ToList(); var driveRootFolder = await group.Drive.Root.Request().GetAsync(); //var schoolTeachers = await educationServiceClient.GetAllTeachersAsync(school.SchoolNumber); var schoolTeachers = await educationServiceClient.GetAllTeachersAsync(school.ExternalId); //this works in our tenant foreach (var sectionTeacher in @class.Teachers) { schoolTeachers = schoolTeachers.Where(t => t.Id != sectionTeacher.Id).ToArray(); } foreach (var user in @class.Students) { var seat = dbContext.ClassroomSeatingArrangements.FirstOrDefault(c => c.O365UserId == user.Id && c.ClassId == classId); user.Position = seat?.Position ?? 0; var userInDB = dbContext.Users.Where(c => c.O365UserId == user.Id).FirstOrDefault(); user.FavoriteColor = userInDB == null ? "" : userInDB.FavoriteColor; } return(new SectionDetailsViewModel { School = school, Class = @class, Conversations = await group.Conversations.Request().GetAllAsync(), //Conversations = Array.Empty<Conversation>(), SeeMoreConversationsUrl = string.Format(Constants.O365GroupConversationsUrl, @class.MailNickname), DriveItems = await group.Drive.Root.Children.Request().GetAllAsync(), //DriveItems = Array.Empty<DriveItem>(), SeeMoreFilesUrl = driveRootFolder.WebUrl, SchoolTeachers = schoolTeachers }); }