Exemplo n.º 1
0
        // Accept a meeting request.
        // If the current user is the organizer of the meeting, the snippet will not work since organizers can't accept their
        // own invitations.
        public async Task <ActionResult> AcceptMeetingRequest(string id)
        {
            ResultsViewModel results = new ResultsViewModel(false);

            try
            {
                // Accept the meeting.
                results.Items = await eventsService.AcceptMeetingRequest(id);
            }
            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));
        }
Exemplo n.º 2
0
        // Accept a meeting request.
        // If the current user is the organizer of the meeting, the snippet will not work since organizers can't accept their
        // own invitations.
        public async Task <ActionResult> AcceptMeetingRequest(string id)
        {
            ResultsViewModel results = new ResultsViewModel(false);

            try
            {
                // Initialize the GraphServiceClient.
                GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();

                // Accept the meeting.
                results.Items = await eventsService.AcceptMeetingRequest(graphClient, id);
            }
            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));
        }