当前位置: 首页>>代码示例>>C#>>正文


C# DefinedValueService.Find方法代码示例

本文整理汇总了C#中Rock.Model.DefinedValueService.Find方法的典型用法代码示例。如果您正苦于以下问题:C# DefinedValueService.Find方法的具体用法?C# DefinedValueService.Find怎么用?C# DefinedValueService.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.DefinedValueService的用法示例。


在下文中一共展示了DefinedValueService.Find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapGiftednessProgram

        /// <summary>
        /// Maps the Giftedness Program.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        private void MapGiftednessProgram( IQueryable<Row> tableData )
        {
            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying Giftedness Program import ({0:N0} found).", totalRows ) );

            foreach ( var row in tableData )
            {
                var rockContext = new RockContext();
                var categoryList = new CategoryService( rockContext ).Queryable().ToList();
                var attributeList = new AttributeService( rockContext ).Queryable().ToList();
                var definedTypeList = new DefinedTypeService( rockContext ).Queryable().ToList();
                var definedValueList = new DefinedValueService( rockContext ).Queryable().ToList();

                //check if category exists
                string category = row["CategoryName"] as string;
                if ( categoryList.Find( c => c.Name == category ) == null )
                {
                    var entityType = new EntityTypeService( rockContext );
                    //creates if category doesn't exist
                    var newCategory = new Category();
                    newCategory.IsSystem = false;
                    newCategory.EntityTypeId = entityType.Queryable().Where( e => e.Name == "Rock.Model.Attribute" ).Select( e => e.Id ).FirstOrDefault();
                    newCategory.EntityTypeQualifierColumn = "EntityTypeId";
                    newCategory.EntityTypeQualifierValue = Convert.ToString( PersonEntityTypeId );  //Convert.ToString(entityType.Queryable().Where( e => e.Name == "Rock.Model.Person" ).Select( e => e.Id ).FirstOrDefault());
                    newCategory.Name = category;
                    newCategory.Description = "Contains the spiritual gifts attributes";

                    //var newCategoryContext = new RockContext();
                    //newCategoryContext.WrapTransaction( () =>
                    //{
                    //    newCategoryContext.Configuration.AutoDetectChangesEnabled = false;
                    //    newCategoryContext.Categories.Add( newCategory );
                    //    newCategoryContext.SaveChanges( DisableAudit );
                    //} );
                    rockContext.WrapTransaction( () =>
                    {
                        rockContext.Configuration.AutoDetectChangesEnabled = false;
                        rockContext.Categories.Add( newCategory );
                        rockContext.SaveChanges( DisableAudit );
                    } );
                }
                //Check if Attribute exists
                if ( attributeList.Find( a => a.Key == "Rank1" ) == null || attributeList.Find( a => a.Key == "Rank2" ) == null || attributeList.Find( a => a.Key == "Rank3" ) == null || attributeList.Find( a => a.Key == "Rank4" ) == null )
                {
                    var fieldType = new FieldTypeService( rockContext );
                    var newAttributeList = new List<Rock.Model.Attribute>();
                    var fieldTypeId = fieldType.Queryable().Where( e => e.Name == "Defined Value" ).FirstOrDefault().Id;
                    var category2 = new CategoryService( rockContext ).Queryable().Where( gt => gt.Name == "Spiritual Gifts" ).FirstOrDefault();

                    if ( attributeList.Find( a => a.Key == "Rank1" ) == null )
                    {
                        //Creates if attribute doesn't exist
                        var newAttribute = new Rock.Model.Attribute();
                        newAttribute.Key = "Rank1";
                        newAttribute.Name = "Rank 1";
                        newAttribute.FieldTypeId = fieldTypeId;
                        newAttribute.EntityTypeId = PersonEntityTypeId;
                        newAttribute.EntityTypeQualifierValue = string.Empty;
                        newAttribute.EntityTypeQualifierColumn = string.Empty;
                        newAttribute.Description = "Rank 1";
                        newAttribute.DefaultValue = string.Empty;
                        newAttribute.IsMultiValue = false;
                        newAttribute.IsRequired = false;
                        newAttribute.Categories = new List<Category>();
                        newAttribute.Categories.Add( category2 );

                        newAttributeList.Add( newAttribute );

                    }
                    if ( attributeList.Find( a => a.Key == "Rank2" ) == null )
                    {
                        //Creates if attribute doesn't exist
                        var newAttribute = new Rock.Model.Attribute();
                        newAttribute.Key = "Rank2";
                        newAttribute.Name = "Rank 2";
                        newAttribute.FieldTypeId = fieldTypeId;
                        newAttribute.EntityTypeId = PersonEntityTypeId;
                        newAttribute.EntityTypeQualifierValue = string.Empty;
                        newAttribute.EntityTypeQualifierColumn = string.Empty;
                        newAttribute.Description = "Rank 2";
                        newAttribute.DefaultValue = string.Empty;
                        newAttribute.IsMultiValue = false;
                        newAttribute.IsRequired = false;
                        newAttribute.Categories = new List<Category>();
                        newAttribute.Categories.Add( category2 );

                        newAttributeList.Add( newAttribute );
                    }
                    if ( attributeList.Find( a => a.Key == "Rank3" ) == null )
                    {
                        //Creates if attribute doesn't exist
                        var newAttribute = new Rock.Model.Attribute();
                        newAttribute.Key = "Rank3";
                        newAttribute.Name = "Rank 3";
//.........这里部分代码省略.........
开发者ID:CrossroadsChristian,项目名称:Excavator,代码行数:101,代码来源:Giftedness.cs


注:本文中的Rock.Model.DefinedValueService.Find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。