public Task <IEnumerable <Rule> > GetAll(Guid tenantId, RulesFilter rulesFilter, Pagination pagination) { IEnumerable <Rule> filteredRules = this.entities.Where(r => r.Key.TenantId == tenantId); if (rulesFilter != null) { if (rulesFilter.ContentTypeCode.HasValue) { filteredRules = filteredRules.Where(r => r.ContentTypeCode == rulesFilter.ContentTypeCode.GetValueOrDefault()); } if (rulesFilter.FilterDateBegin.HasValue && rulesFilter.FilterDateEnd.HasValue) { filteredRules = filteredRules.Where(r => (r.DateBegin >= rulesFilter.FilterDateBegin.GetValueOrDefault() || r.DateEnd.GetValueOrDefault(DateTime.MaxValue) >= rulesFilter.FilterDateBegin.GetValueOrDefault()) && (r.DateBegin < rulesFilter.FilterDateEnd.GetValueOrDefault() || r.DateEnd.GetValueOrDefault(DateTime.MaxValue) < rulesFilter.FilterDateEnd.GetValueOrDefault())); } } if (pagination != null) { filteredRules = filteredRules.Skip(pagination.PageSize * pagination.PageIndex).Take(pagination.PageSize); } return(Task.FromResult(filteredRules)); }
public IDataFilter Parse(JobParser parser, ParseState state) { using (new SecurityDisabler()) { var ruleContextItem = parser.Database.GetRootItem(parser.DefaultLanguage); var json = state.TryGet <string>("Rule"); if (!string.IsNullOrEmpty(json)) { var filter = RulesFilter.FromString(json); filter.RuleContextItem = ruleContextItem; return(filter); } var ruleItem = state.Require <string>("Item", true); Item item; ID id; if (!ID.TryParse(ruleItem, out id)) { if (!ruleItem.StartsWith("/")) { var rootItem = state.Parser.Database.GetItem( ExperienceExtractorApiContainer.ItemPaths.GetOrDefault("experienceAnalyticsFilters") ?? "/sitecore/system/Marketing Control Panel/Experience Analytics/Filters"); ruleItem = rootItem.Paths.FullPath + "/" + ruleItem; } item = parser.Database.GetItem(ruleItem, parser.DefaultLanguage); } else { item = parser.Database.GetItem(id, parser.DefaultLanguage); } if (item == null) { throw ParseException.AttributeError(state, string.Format("Rule item not found '{0}'", ruleItem)); } var rules = RuleFactory.GetRules <RuleContext>(item.Fields["Rule"]); return(new RulesFilter(rules) { RuleContextItem = ruleContextItem }); } }
public async Task <IEnumerable <RuleDto> > GetAll(Guid tenantId, RulesFilterDto rulesFilterDto, PaginationDto paginationDto) { RulesFilter rulesFilter = rulesFilterDto?.ToRulesFilter(); Pagination pagination = paginationDto?.ToPagination(); return(await this.ruleRepository.GetAll(tenantId, rulesFilter, pagination) .ContinueWith(rulesTask => { IEnumerable <Rule> rules = rulesTask.GetAwaiter().GetResult(); return rules.Select(r => this.ConvertToDto(r)); })); }
public Task <IEnumerable <Rule> > GetAll(Guid tenantId, RulesFilter rulesFilter, Pagination pagination) { throw new NotImplementedException(); }