private async Task <SchoolsService> GetSchoolsServiceAsync() { var educationServiceClient = EducationServiceClient.GetEducationServiceClient( await AuthenticationHelper.GetAccessTokenAsync(Constants.Resources.MSGraph, Permissions.Delegated)); return(new SchoolsService(educationServiceClient, dbContext)); }
// // GET: /Manage/AboutMe public async Task <ActionResult> AboutMe(bool?showSaveMessage) { var model = new AboutMeViewModel { FavoriteColors = Constants.FavoriteColors }; var userContext = await applicationService.GetUserContextAsync(); if (userContext.User == null) { model.Username = userContext.UserDisplayName; model.MyFavoriteColor = ""; model.ShowFavoriteColor = false; } else { model.Username = string.IsNullOrEmpty(userContext.User.FullName.Trim()) ? userContext.User.UserName : userContext.User.FullName; model.MyFavoriteColor = userContext.User.FavoriteColor; model.ShowFavoriteColor = true; if (userContext.IsO365Account && string.IsNullOrEmpty(userContext.User.O365UserId)) { model.ShowFavoriteColor = false; } } if (userContext.IsO365Account || userContext.AreAccountsLinked) { var accessToken = await AuthenticationHelper.GetAccessTokenAsync(Constants.Resources.MSGraph, Permissions.Delegated); var educationServiceClient = EducationServiceClient.GetEducationServiceClient(new BearerAuthenticationProvider(accessToken)); var schoolsService = new SchoolsService(educationServiceClient, dbContext); model.Groups.AddRange(await schoolsService.GetMyClassesAsync()); } if (showSaveMessage == true) { TempData["saveresult"] = "<span class='saveresult'>Favorite color has been updated!</span>"; } return(View(model)); }