예제 #1
0
        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);
        }
예제 #2
0
        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
                       ));
        }
예제 #3
0
        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();
        }