本文整理汇总了C#中Rock.Model.CategoryService.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# CategoryService.Contains方法的具体用法?C# CategoryService.Contains怎么用?C# CategoryService.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.CategoryService
的用法示例。
在下文中一共展示了CategoryService.Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindCommentsGrid
/// <summary>
/// Binds the comments grid.
/// </summary>
private void BindCommentsGrid()
{
var rockContext = new RockContext();
var noteTypeService = new NoteTypeService( rockContext );
var noteType = noteTypeService.Get( Rock.SystemGuid.NoteType.PRAYER_COMMENT.AsGuid() );
var noteService = new NoteService( rockContext );
var prayerComments = noteService.GetByNoteTypeId( noteType.Id );
SortProperty sortProperty = gPrayerComments.SortProperty;
// Filter by Category. First see if there is a Block Setting, otherwise use the Grid Filter
CategoryCache categoryFilter = null;
var blockCategoryGuid = GetAttributeValue( "PrayerRequestCategory" ).AsGuidOrNull();
if ( blockCategoryGuid.HasValue )
{
categoryFilter = CategoryCache.Read( blockCategoryGuid.Value );
}
if ( categoryFilter == null && catpPrayerCategoryFilter.Visible )
{
int? filterCategoryId = catpPrayerCategoryFilter.SelectedValue.AsIntegerOrNull();
if ( filterCategoryId.HasValue )
{
categoryFilter = CategoryCache.Read( filterCategoryId.Value );
}
}
if ( categoryFilter != null )
{
// if filtered by category, only show comments for prayer requests in that category or any of its decendent categories
var categoryService = new CategoryService( rockContext );
var categories = new CategoryService( rockContext ).GetAllDescendents( categoryFilter.Guid ).Select( a => a.Id ).ToList();
var prayerRequestQry = new PrayerRequestService( rockContext ).Queryable().Where( a => a.CategoryId.HasValue &&
( a.Category.Guid == categoryFilter.Guid || categories.Contains( a.CategoryId.Value ) ) )
.Select( a => a.Id );
prayerComments = prayerComments.Where( a => a.EntityId.HasValue && prayerRequestQry.Contains( a.EntityId.Value ) );
}
// Filter by Date Range
if ( drpDateRange.LowerValue.HasValue )
{
DateTime startDate = drpDateRange.LowerValue.Value.Date;
prayerComments = prayerComments.Where( a => a.CreatedDateTime.HasValue && a.CreatedDateTime.Value >= startDate );
}
if ( drpDateRange.UpperValue.HasValue )
{
// Add one day in order to include everything up to the end of the selected datetime.
var endDate = drpDateRange.UpperValue.Value.AddDays( 1 );
prayerComments = prayerComments.Where( a => a.CreatedDateTime.HasValue && a.CreatedDateTime.Value < endDate );
}
// Sort by the given property otherwise sort by the EnteredDate
if ( sortProperty != null )
{
gPrayerComments.DataSource = prayerComments.Sort( sortProperty ).ToList();
}
else
{
gPrayerComments.DataSource = prayerComments.OrderByDescending( n => n.CreatedDateTime ).ToList();
}
gPrayerComments.DataBind();
}
示例2: BindFilter
/// <summary>
/// Binds the filter.
/// </summary>
private void BindFilter()
{
// Exclude the categories for block and service job attributes, since they are controlled through code attribute decorations
var exclusions = new List<Guid>();
exclusions.Add( Rock.SystemGuid.EntityType.BLOCK.AsGuid() );
exclusions.Add( Rock.SystemGuid.EntityType.SERVICE_JOB.AsGuid() );
var rockContext = new RockContext();
var entityTypes = new EntityTypeService( rockContext ).GetEntities()
.Where( t => !exclusions.Contains( t.Guid ) )
.OrderBy( t => t.FriendlyName )
.ToList();
entityTypePicker.EntityTypes = entityTypes;
// Load Entity Type Filter
var attributeEntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id;
var categoryEntities = new CategoryService( rockContext ).Queryable()
.Where( c =>
c.EntityTypeId == attributeEntityTypeId &&
c.EntityTypeQualifierColumn == "EntityTypeId" &&
c.EntityTypeQualifierValue != null )
.Select( c => c.EntityTypeQualifierValue )
.ToList()
.Select( c => c.AsInteger() );
entityTypeFilter.EntityTypes = entityTypes.Where( e => categoryEntities.Contains( e.Id ) ).ToList();
entityTypeFilter.SelectedValue = rFilter.GetUserPreference( "EntityType" );
}
示例3: BindCommentsGrid
/// <summary>
/// Binds the comments grid.
/// </summary>
private void BindCommentsGrid()
{
var rockContext = new RockContext();
var noteTypeService = new NoteTypeService( rockContext );
var noteType = noteTypeService.Get( Rock.SystemGuid.NoteType.PRAYER_COMMENT.AsGuid() );
// TODO log exception if noteType is null
var noteService = new NoteService( rockContext );
var prayerComments = noteService.GetByNoteTypeId( noteType.Id );
SortProperty sortProperty = gPrayerComments.SortProperty;
if ( _blockInstancePrayerRequestCategoryGuid.HasValue )
{
// if filtered by category, only show comments for prayer requests in that category or any of its decendent categories
var categoryService = new CategoryService( rockContext );
if ( _blockInstancePrayerRequestCategoryGuid.HasValue )
{
var categories = new CategoryService( rockContext ).GetAllDescendents( _blockInstancePrayerRequestCategoryGuid.Value ).Select( a => a.Id ).ToList();
var prayerRequestQry = new PrayerRequestService( rockContext ).Queryable().Where( a => a.CategoryId.HasValue &&
( a.Category.Guid == _blockInstancePrayerRequestCategoryGuid.Value || categories.Contains( a.CategoryId.Value ) ) )
.Select( a => a.Id );
prayerComments = prayerComments.Where( a => a.EntityId.HasValue && prayerRequestQry.Contains( a.EntityId.Value ) );
}
}
// Filter by Date Range
if ( drpDateRange.LowerValue.HasValue )
{
DateTime startDate = drpDateRange.LowerValue.Value.Date;
prayerComments = prayerComments.Where( a => a.CreatedDateTime.HasValue && a.CreatedDateTime.Value >= startDate );
}
if ( drpDateRange.UpperValue.HasValue )
{
// Add one day in order to include everything up to the end of the selected datetime.
var endDate = drpDateRange.UpperValue.Value.AddDays( 1 );
prayerComments = prayerComments.Where( a => a.CreatedDateTime.HasValue && a.CreatedDateTime.Value < endDate );
}
// Sort by the given property otherwise sort by the EnteredDate
if ( sortProperty != null )
{
gPrayerComments.DataSource = prayerComments.Sort( sortProperty ).ToList();
}
else
{
gPrayerComments.DataSource = prayerComments.OrderBy( n => n.CreatedDateTime ).ToList();
}
gPrayerComments.DataBind();
}
示例4: GetByCategory
public IQueryable<PrayerRequest> GetByCategory( int categoryId )
{
var rockContext = ( this.Service.Context as RockContext ) ?? new RockContext();
var decendentsCategoriesQry = new CategoryService( rockContext ).GetAllDescendents( categoryId ).Select( a => a.Id );
return this.Get().Where( a => a.CategoryId.HasValue ).Where( a => decendentsCategoriesQry.Contains( a.CategoryId.Value ) || ( a.CategoryId.Value == categoryId ) );
}