public async Task <ActionResult> Index(string channelId) { var accessToken = await AadHelper.GetAccessToken(); var repo = new VideoChannelRepository(accessToken); var channel = await repo.GetChannel(channelId); var videos = await repo.GetChannelVideos(channelId); var viewModel = new VideoListViewModel { ChannelId = channelId, ChannelTitle = channel.Title, Videos = videos }; return(View(viewModel)); }
public async Task <ActionResult> Index(string channelId) { try { var accessTokenSharePoint = await AadHelper.GetAccessTokenForSharePoint(); var accessTokenMSGraph = await AadHelper.GetAccessTokenForMicrosoftGraph(); var sharePointRepository = new VideoChannelRepository(accessTokenSharePoint); var groupsRepository = new GroupsRepository(graphClient); var subscriptionsRepository = new SubscriptionsRepository(graphClient, this.Session, HttpRuntime.Cache); var channel = await sharePointRepository.GetChannel(channelId); var videos = await sharePointRepository.GetChannelVideos(channelId); var groups = await groupsRepository.GetGroups(); var viewModel = new VideoListViewModel { ChannelId = channelId, ChannelTitle = channel.Title, Videos = videos, Groups = groups }; // integration of the webhooks example Microsoft.Graph.Subscription result = await subscriptionsRepository.CreateOrReuseSubscription(); return(View(viewModel)); } catch (Exception ex) { if (ex is AdalException) { // let the ActionFilterAttribute take care of it throw ex; } return(RedirectToAction("Index", "Error", new { message = ex.Message })); } }