示例#1
0
        public ActionResult MembershipStatistics(UserGroup userGroup, UserGroupMembership userGroupMembership, User currentUser)
        {
            Require.NotNull(userGroup, "userGroup");
            Require.NotNull(userGroupMembership, "userGroupMembership");
            Require.IsTrue(() => userGroupMembership.UserGroup.Equals(userGroup), "userGroupMembership");
            Require.IsFalse(() => userGroupMembership.MembershipType == UserGroupMembershipType.Quit, "userGroupMembership");

            UserGroupMembership         currentUsersMembershipInGroup = UserGroupService.FindMembershipsByUserAndGroup(currentUser, userGroup);
            IList <UserGroupMembership> members =
                UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                         new List <UserGroup> {
                userGroup
            },
                                                         new List <UserGroupMembershipType> {
                UserGroupMembershipType.Administrator, UserGroupMembershipType.Member
            }).ToList();


            IDictionary <UserGroupMembership, int> userGroupMembersKarma = PeanutService.GetUserGroupMembersKarma(userGroup);

            return(View("UserGroupMembershipStatistics",
                        new UserGroupMembershipStatisticsViewModel(userGroupMembership,
                                                                   members,
                                                                   new UserGroupMembershipOptions(userGroupMembership, currentUsersMembershipInGroup),
                                                                   PeanutService.GetPeanutsUserGroupMembershipStatistics(userGroupMembership),
                                                                   userGroupMembersKarma
                                                                   )));
        }
示例#2
0
        public ActionResult MembershipDetails(UserGroup userGroup, UserGroupMembership userGroupMembership, User currentUser)
        {
            Require.NotNull(userGroup, "userGroup");
            Require.NotNull(userGroupMembership, "userGroupMembership");
            Require.IsTrue(() => userGroupMembership.UserGroup.Equals(userGroup), "userGroupMembership");
            Require.IsFalse(() => userGroupMembership.MembershipType == UserGroupMembershipType.Quit, "userGroupMembership");

            IList <UserGroupMembership> members =
                UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                         new List <UserGroup> {
                userGroup
            },
                                                         new List <UserGroupMembershipType> {
                UserGroupMembershipType.Administrator, UserGroupMembershipType.Member
            }).ToList();

            UserGroupMembership currentUsersMembershipInGroup = UserGroupService.FindMembershipsByUserAndGroup(currentUser, userGroup);

            IPage <Peanut> peanuts = new Page <Peanut>(new List <Peanut>(), 0);

            if (userGroupMembership.MembershipType == UserGroupMembershipType.Administrator)
            {
                peanuts = PeanutService.FindAllPeanutsInGroup(userGroup);
            }
            return(View("UserGroupMembershipDetails",
                        new UserGroupMembershipDetailsViewModel(userGroupMembership,
                                                                members,
                                                                new UserGroupMembershipOptions(userGroupMembership, currentUsersMembershipInGroup), peanuts)));
        }
示例#3
0
        public ActionResult AcceptMembershipRequest(UserGroup userGroup, UserGroupMembership userGroupMembership, User currentUser)
        {
            Require.NotNull(userGroupMembership, "userGroupMembership");
            Require.NotNull(userGroup, "userGroup");
            Require.IsTrue(() => userGroupMembership.MembershipType == UserGroupMembershipType.Request, "userGroupMembership");

            UserGroupMembership currentUsersMembership = UserGroupService.FindMembershipsByUserAndGroup(currentUser, userGroupMembership.UserGroup);

            Require.IsTrue(() => currentUsersMembership != null && currentUsersMembership.MembershipType == UserGroupMembershipType.Administrator,
                           "userGroupMembership");

            UserGroupService.UpdateMembershipTypes(
                new Dictionary <UserGroupMembership, UserGroupMembershipType> {
                { userGroupMembership, UserGroupMembershipType.Member }
            },
                currentUser);
            string urlToUserGroup = Url.Action("Membership",
                                               "UserGroup",
                                               new { userGroup = userGroup.BusinessId, userGroupMembership = userGroupMembership.BusinessId },
                                               Request.Url.Scheme);

            NotificationService.SendConfirmMembershipNotification(userGroupMembership.User, userGroupMembership.UserGroup, urlToUserGroup);
            return(RedirectToAction("AllMemberships"));
        }