private static List <Expression <Func <Workflow, bool> > > GetCriterias( WorkflowSearchPagingParameters pagingParameters ) { List <Expression <Func <Workflow, bool> > > criterias = new List <Expression <Func <Workflow, bool> > >(); if (pagingParameters.HasType) { criterias.Add(w => w.Type.ToLower() .StartsWith(pagingParameters.Type.ToLower())); } if (pagingParameters.HasCorrelationId) { criterias.Add( w => w.CorrelationId == pagingParameters.CorrelationId); } if (pagingParameters.HasAssignee) { criterias.Add(w => w.Assignee.ToLower() .StartsWith(pagingParameters.Assignee.ToLower())); } return(criterias); }
public async Task <PaginatedList <WorkflowDto> > GetWorkflowsAsync( WorkflowSearchPagingParameters pagingParameters ) { var count = await this.repository.CountAsync(new WorkflowCount()); IReadOnlyList <Workflow> instances = null; if (pagingParameters.HasValues) { instances = await this.repository .ListAsync(new WorkflowInstancesFilterAndOrderedPaginated( pagingParameters )); } else { instances = await this.repository .ListAsync(new WorkflowInstancesOrderedPaginated( pagingParameters.SkipCount, pagingParameters.PageSize )); } var items = instances.Select(i => this.ToWorkflowDto(i)); return(new PaginatedList <WorkflowDto>( items, count, pagingParameters.PageIndex, pagingParameters.PageSize )); }
public WorkflowInstancesFilterAndOrderedPaginated( WorkflowSearchPagingParameters pagingParameters ) : base() { var criterias = GetCriterias(pagingParameters); foreach (var criteria in criterias) { this.AddCriteria(criteria); } this.ApplyOrderByDescending(w => w.Id); this.ApplyPaging(pagingParameters.SkipCount, pagingParameters.PageSize); this.ApplyNoTracking(); }