Пример #1
0
        public ActionResult QuitMembership(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");

            if (!ModelState.IsValid)
            {
                return(QuitMembershipForm(userGroup, userGroupMembership, currentUser));
            }

            UserGroupService.QuitOrRemoveMemberships(new[] { userGroupMembership }, currentUser);
            return(RedirectToAction("AllMemberships", "UserGroup"));
        }