GetByDefinedTypeGuid() публичный Метод

Returns an enumerable collection of Rock.Model.DefinedValue">DefinedValues that belong to a specified
public GetByDefinedTypeGuid ( System.Guid definedTypeGuid ) : IOrderedQueryable
definedTypeGuid System.Guid A representing the Guid identifier of the to retrieve DefinedValues /// for.
Результат IOrderedQueryable
        /// <summary>
        /// Handles the Add event of the gLocationTypes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void gLocationTypes_Add( object sender, EventArgs e )
        {
            DefinedValueService definedValueService = new DefinedValueService( new RockContext() );

            // populate dropdown with all locationtypes that aren't already locationtypes
            var qry = from dlt in definedValueService.GetByDefinedTypeGuid( new Guid( Rock.SystemGuid.DefinedType.GROUP_LOCATION_TYPE ) )
                      where !( from lt in LocationTypesDictionary.Keys
                               select lt ).Contains( dlt.Id )
                      select dlt;

            List<DefinedValue> list = qry.ToList();
            if ( list.Count == 0 )
            {
                modalAlert.Show( "There are not any location types defined.  Before you can add location types to a group type, you will first need to add them using Defined Type/Values", ModalAlertType.Warning );
            }
            else
            {
                ddlLocationType.DataSource = list;
                ddlLocationType.DataBind();
                ShowDialog( "LocationType" );
            }
        }
Пример #2
0
        /// <summary>
        /// Gs the marketing campaign audiences add.
        /// </summary>
        /// <param name="primaryAudience">if set to <c>true</c> [is primary].</param>
        private void gMarketingCampaignAudiencesAdd( bool primaryAudience )
        {
            DefinedValueService definedValueService = new DefinedValueService( new RockContext() );

            // populate dropdown with all MarketingCampaignAudiences that aren't already MarketingCampaignAudiences
            var guid = Rock.SystemGuid.DefinedType.MARKETING_CAMPAIGN_AUDIENCE_TYPE.AsGuid();
            var existingAudiences = MarketingCampaignAudiencesState.Select( s => s.AudienceTypeValueId ).ToList();
            var qry = definedValueService.GetByDefinedTypeGuid( guid )
                .Where( v => !existingAudiences.Contains( v.Id ) );

            List<DefinedValue> list = qry.ToList();
            if ( list.Count == 0 )
            {
                list.Add( new DefinedValue { Id = None.Id, Value = None.Text } );
                btnAddMarketingCampaignAudience.Enabled = false;
                btnAddMarketingCampaignAudience.CssClass = "btn btn-primary disabled";
            }
            else
            {
                btnAddMarketingCampaignAudience.Enabled = true;
                btnAddMarketingCampaignAudience.CssClass = "btn btn-primary";
            }

            ddlMarketingCampaignAudiences.DataSource = list;
            ddlMarketingCampaignAudiences.DataBind();
            hfMarketingCampaignAudienceIsPrimary.Value = primaryAudience.ToTrueFalse();
            pnlMarketingCampaignAudiencePicker.Visible = true;
            pnlDetails.Visible = false;
        }
Пример #3
0
        /// <summary>
        /// Gs the marketing campaign audiences add.
        /// </summary>
        /// <param name="primaryAudience">if set to <c>true</c> [is primary].</param>
        private void gMarketingCampaignAudiencesAdd( bool primaryAudience )
        {
            DefinedValueService definedValueService = new DefinedValueService();

            // populate dropdown with all MarketingCampaignAudiences that aren't already MarketingCampaignAudiences
            var qry = from audienceTypeValue in definedValueService.GetByDefinedTypeGuid( new Guid( Rock.SystemGuid.DefinedType.MARKETING_CAMPAIGN_AUDIENCE_TYPE ) ).AsQueryable()
                      where !( from mcaudience in MarketingCampaignAudiencesState
                               select mcaudience.AudienceTypeValueId ).Contains( audienceTypeValue.Id )
                      select audienceTypeValue;

            List<DefinedValue> list = qry.ToList();
            if ( list.Count == 0 )
            {
                list.Add( new DefinedValue { Id = None.Id, Name = None.Text } );
                btnAddMarketingCampaignAudience.Enabled = false;
                btnAddMarketingCampaignAudience.CssClass = "btn btn-primary disabled";
            }
            else
            {
                btnAddMarketingCampaignAudience.Enabled = true;
                btnAddMarketingCampaignAudience.CssClass = "btn btn-primary";
            }

            ddlMarketingCampaignAudiences.DataSource = list;
            ddlMarketingCampaignAudiences.DataBind();
            hfMarketingCampaignAudienceIsPrimary.Value = primaryAudience.ToTrueFalse();
            pnlMarketingCampaignAudiencePicker.Visible = true;
            pnlDetails.Visible = false;
        }