示例#1
0
        public async Task <IViewComponentResult> InvokeForUserAsync(string siteId, Identity.Models.User user)
        {
            var groups = await _userGroupManager.GetPublicUserGroupsForUserAndSiteAsync(user.Id, siteId, Models.UserGroupType.NotificationGroup);

            var model = new List <UserMembershipViewModel>();

            foreach (var group in groups)
            {
                model.Add(new UserMembershipViewModel()
                {
                    UserGroupId           = group.UserGroupId,
                    UserGroupName         = group.UserGroup.Name,
                    AllowPublicEnrollment = group.UserGroup.AllowPublicEnrollment,
                    AllowEmailMessaging   = group.AllowEmailMessaging,
                    AllowSmsMessaging     = group.AllowSmsMessaging,
                    IsMember = (group.UserId != null)
                });
            }
            model = model.OrderBy(m => m.UserGroupName).ToList();

            ViewData["userId"] = user.Id;
            ViewData["siteId"] = siteId;

            return(View("NotifyMeEditList", model));
        }
示例#2
0
        public async Task <IViewComponentResult> InvokeAsync(string userId, string siteId, string userGroupType)
        {
            var user = await _userManager.GetUserAsync(userId);

            if (user == null)
            {
                throw new Exception("Unable to find user: "******"userId"]         = userId;
            ViewData["siteId"]         = siteId;
            ViewData["emailConfirmed"] = user.EmailConfirmed;
            ViewData["smsConfirmed"]   = user.PhoneNumberConfirmed;

            var groupType = userGroupType.ToEnumOrDefault(Models.UserGroupType.NotificationGroup);
            var groups    = await _userGroupManager.GetPublicUserGroupsForUserAndSiteAsync(userId, siteId, groupType);

            var model = new List <UserMembershipViewModel>();

            foreach (var group in groups)
            {
                model.Add(new UserMembershipViewModel()
                {
                    UserGroupId           = group.UserGroupId,
                    UserGroupName         = group.UserGroup.Name,
                    AllowPublicEnrollment = group.UserGroup.AllowPublicEnrollment,
                    AllowEmailMessaging   = group.AllowEmailMessaging,
                    AllowSmsMessaging     = group.AllowSmsMessaging,
                    IsMember = (group.UserId != null)
                });
            }
            model = model.OrderBy(m => m.UserGroupName).ToList();

            return(View("UserMemberships", model));
        }