Example #1
0
    /// <summary>
    /// Gets and bulk updates relationship names. Called when the "Get and bulk update names" button is pressed.
    /// Expects the CreateRelationshipName method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateRelationshipNames()
    {
        // Prepare the parameters
        string where = "RelationshipName LIKE N'MyNewRelationshipName%'";

        // Get the data
        DataSet names = RelationshipNameInfoProvider.GetRelationshipNames(where, null);

        if (!DataHelper.DataSourceIsEmpty(names))
        {
            // Loop through the individual items
            foreach (DataRow nameDr in names.Tables[0].Rows)
            {
                // Create object from DataRow
                RelationshipNameInfo modifyName = new RelationshipNameInfo(nameDr);

                // Update the properties
                modifyName.RelationshipDisplayName = modifyName.RelationshipDisplayName.ToUpper();

                // Save the changes
                RelationshipNameInfoProvider.SetRelationshipNameInfo(modifyName);
            }

            return(true);
        }

        return(false);
    }
Example #2
0
    /// <summary>
    /// Saves data of edited relationship name from TextBoxes into DB.
    /// </summary>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Finds whether required fields are not empty
        string result = new Validator().NotEmpty(txtRelationshipNameDisplayName.Text, GetString("General.RequiresDisplayName")).NotEmpty(txtRelationshipNameCodeName.Text, GetString("General.RequiresCodeName"))
                        .IsCodeName(txtRelationshipNameCodeName.Text, GetString("general.invalidcodename"))
                        .Result;

        if (result == string.Empty)
        {
            if (relationshipNameId > 0)
            {
                // Check the uniqueness of code name
                RelationshipNameInfo rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(txtRelationshipNameCodeName.Text);
                if (rni == null || rni.RelationshipNameId == relationshipNameId)
                {
                    // Get relationshipname info by ID
                    rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameId);
                    if (rni != null)
                    {
                        if (rni.RelationshipDisplayName != txtRelationshipNameDisplayName.Text)
                        {
                            // Refresh header
                            ScriptHelper.RefreshTabHeader(Page, null);
                        }

                        rni.RelationshipDisplayName    = txtRelationshipNameDisplayName.Text;
                        rni.RelationshipName           = txtRelationshipNameCodeName.Text;
                        rni.RelationshipAllowedObjects = drpRelType.SelectedValue;
                        // Save changes
                        RelationshipNameInfoProvider.SetRelationshipNameInfo(rni);

                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                    else
                    {
                        lblError.Visible = true;
                        lblError.Text    = GetString("RelationshipNames.RelationshipNameDoesNotExists");
                    }
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("RelationshipNames.RelationshipNameAlreadyExists");
                }
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = result;
        }
    }
Example #3
0
    /// <summary>
    /// Creates relationship name. Called when the "Create name" button is pressed.
    /// </summary>
    private bool CreateRelationshipName()
    {
        // Create new relationship name object
        RelationshipNameInfo newName = new RelationshipNameInfo();

        // Set the properties
        newName.RelationshipDisplayName = "My new relationship name";
        newName.RelationshipName        = "MyNewRelationshipName";

        // Save the relationship name
        RelationshipNameInfoProvider.SetRelationshipNameInfo(newName);

        return(true);
    }
    /// <summary>
    /// Saves new relationship name's data into DB.
    /// </summary>
    /// <returns>Returns ID of created relationship name</returns>
    protected int SaveNewRelationshipName()
    {
        RelationshipNameInfo rni = new RelationshipNameInfo();

        rni.RelationshipDisplayName    = txtRelationshipNameDisplayName.Text;
        rni.RelationshipName           = txtRelationshipNameCodeName.Text;
        rni.RelationshipAllowedObjects = objectTypeSelector.ObjectType;
        RelationshipNameInfoProvider.SetRelationshipNameInfo(rni);
        if (chkAssign.Visible && chkAssign.Checked && (CMSContext.CurrentSite != null) && (rni.RelationshipNameId > 0))
        {
            // Add new relationship name to the actual site
            RelationshipNameSiteInfoProvider.AddRelationshipNameToSite(rni.RelationshipNameId, CMSContext.CurrentSite.SiteID);
        }
        return(rni.RelationshipNameId);
    }
Example #5
0
    /// <summary>
    /// Gets and updates relationship name. Called when the "Get and update name" button is pressed.
    /// Expects the CreateRelationshipName method to be run first.
    /// </summary>
    private bool GetAndUpdateRelationshipName()
    {
        // Get the relationship name
        RelationshipNameInfo updateName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName");

        if (updateName != null)
        {
            // Update the properties
            updateName.RelationshipDisplayName = updateName.RelationshipDisplayName.ToLower();

            // Save the changes
            RelationshipNameInfoProvider.SetRelationshipNameInfo(updateName);

            return(true);
        }

        return(false);
    }