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 ))); }
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))); }
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))); }
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)); }
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")); }
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))); }