コード例 #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 InviteForm(UserGroup userGroup)
        {
            Require.NotNull(userGroup, "userGroup");

            IPage <UserGroupMembership> membersOfGroup = UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                                                                  new List <UserGroup> {
                userGroup
            },
                                                                                                  new List <UserGroupMembershipType> {
                UserGroupMembershipType.Administrator, UserGroupMembershipType.Member
            });
            IList <User> invitableUsers = UserService.GetAll().Except(membersOfGroup.Select(mem => mem.User)).ToList();

            return(View("Invite", new UserGroupMembershipInvitationViewModel(userGroup, invitableUsers)));
        }
コード例 #4
0
        public ActionResult Show(UserGroup userGroup)
        {
            Require.NotNull(userGroup, nameof(userGroup));


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

            return(View(userGroupShowViewModel));
        }
コード例 #5
0
        public ActionResult Invite(UserGroup userGroup, User user, User currentUser)
        {
            Require.NotNull(userGroup, "userGroup");

            if (!ModelState.IsValid)
            {
                IPage <UserGroupMembership> membersOfGroup = UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                                                                      new List <UserGroup> {
                    userGroup
                },
                                                                                                      new List <UserGroupMembershipType> {
                    UserGroupMembershipType.Administrator, UserGroupMembershipType.Member
                });
                IList <User> invitableUsers = UserService.GetAll().Except(membersOfGroup.Select(mem => mem.User)).ToList();
                return(View("Invite", new UserGroupMembershipInvitationViewModel(userGroup, invitableUsers)));
            }
            string allMembershipsUrl = Url.Action("AllMemberships", "UserGroup", null, Request.Url.Scheme);

            UserGroupService.Invite(userGroup, user, currentUser, allMembershipsUrl);

            return(RedirectToAction("AllMemberships"));
        }
コード例 #6
0
        public ActionResult AllMemberships(User currentUser)
        {
            IList <UserGroupMembership> currentMemberships =
                UserGroupService.FindMembershipsByUser(PageRequest.All,
                                                       currentUser,
                                                       new List <UserGroupMembershipType> {
                UserGroupMembershipType.Administrator, UserGroupMembershipType.Member
            }).ToList();
            IList <UserGroupMembership> myRequestedMemberships =
                UserGroupService.FindMembershipsByUser(PageRequest.All,
                                                       currentUser,
                                                       new List <UserGroupMembershipType> {
                UserGroupMembershipType.Request
            }).ToList();
            IList <UserGroupMembership> invitations =
                UserGroupService.FindMembershipsByUser(PageRequest.All,
                                                       currentUser,
                                                       new List <UserGroupMembershipType> {
                UserGroupMembershipType.Invited
            }).ToList();

            IList <UserGroupMembership> myGroups =
                UserGroupService.FindMembershipsByUser(PageRequest.All,
                                                       currentUser,
                                                       new List <UserGroupMembershipType> {
                UserGroupMembershipType.Administrator
            }).ToList();
            IList <UserGroupMembership> requestedMembershipsInMyGroup =
                UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                         myGroups.Select(mem => mem.UserGroup).ToList(),
                                                         new List <UserGroupMembershipType> {
                UserGroupMembershipType.Request
            }).ToList();

            return(View(new UserGroupIndexViewModel(currentMemberships, myRequestedMemberships, invitations, requestedMembershipsInMyGroup)));
        }