// Get user's calendar view. public async Task <ActionResult> GetMyCalendarView() { ResultsViewModel results = new ResultsViewModel(); try { // Get a calendar view. results.Items = await eventsService.GetMyCalendarView(); } catch (ServiceException se) { if ((se.InnerException as AuthenticationException)?.Error.Code == Resource.Error_AuthChallengeNeeded) { HttpContext.Request.GetOwinContext().Authentication.Challenge(); return(new EmptyResult()); } return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(View("Events", results)); }
// Get user's calendar view. public async Task <ActionResult> GetMyCalendarView() { ResultsViewModel results = new ResultsViewModel(); try { // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); // Get a calendar view. results.Items = await eventsService.GetMyCalendarView(graphClient); } catch (ServiceException se) { if (se.Error.Message == Resource.Error_AuthChallengeNeeded) { return(new EmptyResult()); } // Personal accounts that aren't enabled for the Outlook REST API get a "MailboxNotEnabledForRESTAPI" or "MailboxNotSupportedForRESTAPI" error. return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(View("Events", results)); }