Exemplo n.º 1
0
    /// <summary>
    /// Handles UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of the action which should be performed</param>
    /// <param name="actionArgument">ID of the item the action should be performed with</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int membershipId = ValidationHelper.GetInteger(actionArgument, 0);

        if (membershipId > 0)
        {
            switch (actionName.ToLowerCSafe())
            {
            case "edit":
                SelectedItemID = membershipId;
                RaiseOnEdit();
                break;

            case "delete":
                if (CheckPermissions("CMS.Membership", PERMISSION_MODIFY))
                {
                    // Check dependencies
                    if (MembershipInfoProvider.CheckDependencies(membershipId))
                    {
                        ShowError(GetString("membership.dependencies"));
                        return;
                    }

                    // Delete the object
                    MembershipInfoProvider.DeleteMembershipInfo(membershipId);
                    RaiseOnDelete();

                    // Reload data
                    gridElem.ReloadData();
                }
                break;
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Deletes membership. Called when the "Delete membership" button is pressed.
    /// Expects the CreateMembership method to be run first.
    /// </summary>
    private bool DeleteMembership()
    {
        // Get the membership
        MembershipInfo deleteMembership = MembershipInfoProvider.GetMembershipInfo("MyNewMembership", CMSContext.CurrentSiteName);

        // Delete the membership
        MembershipInfoProvider.DeleteMembershipInfo(deleteMembership);

        return(deleteMembership != null);
    }