Пример #1
0
    protected void gvMembers_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }

        if (e.CommandName.CompareOrdinalIgnoreCase("_Delete") == 0)
        {
            ClubMember cm = CurrentClub.Members.FirstOrDefault(pf => pf.UserName.CompareOrdinalIgnoreCase(e.CommandArgument.ToString()) == 0);
            if (cm != null)
            {
                if (cm.RoleInClub == ClubMember.ClubMemberRole.Owner)
                {
                    lblManageMemberError.Text = Resources.Club.errCannotDeleteOwner;
                }
                else
                {
                    if (!cm.FDeleteClubMembership())
                    {
                        lblManageMemberError.Text = cm.LastError;
                    }
                    else
                    {
                        CurrentClub.InvalidateMembers();
                        gvMembers.DataSource = CurrentClub.Members;
                        gvMembers.DataBind();
                    }
                }
            }
        }
    }
Пример #2
0
    protected void lnkLeaveGroup_Click(object sender, EventArgs e)
    {
        // Find the current user in the club members.
        ClubMember cm = CurrentClub.Members.FirstOrDefault(pf => String.Compare(pf.UserName, Page.User.Identity.Name, StringComparison.Ordinal) == 0);

        if (cm.RoleInClub == ClubMember.ClubMemberRole.Member)
        {
            cm.FDeleteClubMembership();
            Club.ClearCachedClub(cm.ClubID);
            Response.Redirect(Request.Path);
        }
    }