Example #1
0
    /// <summary>
    /// Gets and bulk updates states. Called when the "Get and bulk update states" button is pressed.
    /// Expects the CreateState method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateStates()
    {
        // Get the country
        CountryInfo country = CountryInfoProvider.GetCountryInfo("MyNewCountry");

        if (country != null)
        {
            // Get the data
            DataSet states = StateInfoProvider.GetCountryStates(country.CountryID);
            if (!DataHelper.DataSourceIsEmpty(states))
            {
                // Loop through the individual items
                foreach (DataRow stateDr in states.Tables[0].Rows)
                {
                    // Create object from DataRow
                    StateInfo modifyState = new StateInfo(stateDr);

                    // Update the property
                    modifyState.StateDisplayName = modifyState.StateDisplayName.ToUpper();

                    // Update the state
                    StateInfoProvider.SetStateInfo(modifyState);
                }

                return(true);
            }
        }

        return(false);
    }
Example #2
0
    /// <summary>
    /// Gets and updates state. Called when the "Get and update state" button is pressed.
    /// Expects the CreateState method to be run first.
    /// </summary>
    private bool GetAndUpdateState()
    {
        // Get the state
        StateInfo updateState = StateInfoProvider.GetStateInfo("MyNewState");

        if (updateState != null)
        {
            // Update the property
            updateState.StateDisplayName = updateState.StateDisplayName.ToLower();

            // Update the state
            StateInfoProvider.SetStateInfo(updateState);

            return(true);
        }

        return(false);
    }
Example #3
0
    /// <summary>
    /// Creates state. Called when the "Create state" button is pressed.
    /// </summary>
    private bool CreateState()
    {
        // Get the country
        CountryInfo country = CountryInfoProvider.GetCountryInfo("MyNewCountry");

        if (country != null)
        {
            // Create new state object
            StateInfo newState = new StateInfo();

            // Set the properties
            newState.StateDisplayName = "My new state";
            newState.StateName        = "MyNewState";
            newState.CountryID        = country.CountryID;

            // Create the state
            StateInfoProvider.SetStateInfo(newState);

            return(true);
        }

        return(false);
    }