コード例 #1
0
        public IActionResult Details(int id)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (_groupsService.IsMember(id, userId))
            {
                var user = _usersService.GetUser(userId);
                ViewBag.Name   = user.FirstName + " " + user.LastName;
                ViewBag.UserId = userId;
                var model = _mapper.Map <DetailsGroupModel>(_groupsService.GetGroupWithGroupedTopics(userId, id));

                _groupsService.UpdateLastVisitedGroup(userId, id);

                return(View(model));
            }

            var group = _mapper.Map <JoinGroupModel>(_groupsService.GetGroup(id));

            if (group != null)
            {
                return(View("Join", group));
            }

            return(NotFound());
        }
コード例 #2
0
        // Get a specified group.
        // This snippet requires an admin work account.
        public async Task <ActionResult> GetGroup(string id)
        {
            ResultsViewModel results = new ResultsViewModel();

            try
            {
                // Get the group.
                results.Items = await groupsService.GetGroup(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("Groups", results));
        }
コード例 #3
0
        // Get a specified group.
        // This snippet requires an admin work account.
        public async Task <ActionResult> GetGroup(string id)
        {
            ResultsViewModel results = new ResultsViewModel();

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

                // Get the group.
                results.Items = await groupsService.GetGroup(graphClient, id);
            }
            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));
        }