Ejemplo n.º 1
0
        // Get the groups that the current user is a direct member of.
        // This snippet requires an admin work account.
        public async Task <ActionResult> GetMyMemberOfGroups()
        {
            ResultsViewModel results = new ResultsViewModel();

            try
            {
                // Get groups the current user is a direct member of.
                results.Items = await groupsService.GetMyMemberOfGroups();
            }
            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("Groups", results));
        }
Ejemplo n.º 2
0
        // Get the groups that the current user is a direct member of.
        // This snippet requires an admin work account.
        public async Task <ActionResult> GetMyMemberOfGroups()
        {
            ResultsViewModel results = new ResultsViewModel();

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

                // Get groups the current user is a direct member of.
                results.Items = await groupsService.GetMyMemberOfGroups(graphClient);
            }
            catch (ServiceException se)
            {
                if (se.Error.Message == Resource.Error_AuthChallengeNeeded)
                {
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) }));
            }
            return(View("Groups", results));
        }