public object Get(WorkflowSearch request) => GetSearchResultWithCache <Workflow, DocEntityWorkflow, WorkflowSearch>(DocConstantModelName.WORKFLOW, request, _ExecSearch);
private IQueryable <DocEntityWorkflow> _ExecSearch(WorkflowSearch request, DocQuery query) { request = InitSearch <Workflow, WorkflowSearch>(request); IQueryable <DocEntityWorkflow> entities = null; query.Run(session => { entities = query.SelectAll <DocEntityWorkflow>(); if (!DocTools.IsNullOrEmpty(request.FullTextSearch)) { var fts = new WorkflowFullTextSearch(request); entities = GetFullTextSearch <DocEntityWorkflow, WorkflowFullTextSearch>(fts, entities); } if (null != request.Ids && request.Ids.Any()) { entities = entities.Where(en => en.Id.In(request.Ids)); } if (!DocTools.IsNullOrEmpty(request.Updated)) { entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date); } if (!DocTools.IsNullOrEmpty(request.UpdatedBefore)) { entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore); } if (!DocTools.IsNullOrEmpty(request.UpdatedAfter)) { entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter); } if (!DocTools.IsNullOrEmpty(request.Created)) { entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date); } if (!DocTools.IsNullOrEmpty(request.CreatedBefore)) { entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore); } if (!DocTools.IsNullOrEmpty(request.CreatedAfter)) { entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter); } if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.WORKFLOW, nameof(Reference.Archived), DocConstantPermission.VIEW)) { entities = entities.Where(en => en.Archived.In(request.Archived)); } else { entities = entities.Where(en => !en.Archived); } if (true == request.Locked?.Any()) { entities = entities.Where(en => en.Locked.In(request.Locked)); } if (true == request.BindingsIds?.Any()) { entities = entities.Where(en => en.Bindings.Any(r => r.Id.In(request.BindingsIds))); } if (!DocTools.IsNullOrEmpty(request.Description)) { entities = entities.Where(en => en.Description.Contains(request.Description)); } if (!DocTools.IsNullOrEmpty(request.Descriptions)) { entities = entities.Where(en => en.Description.In(request.Descriptions)); } if (true == request.DocumentsIds?.Any()) { entities = entities.Where(en => en.Documents.Any(r => r.Id.In(request.DocumentsIds))); } if (!DocTools.IsNullOrEmpty(request.DocumentSet) && !DocTools.IsNullOrEmpty(request.DocumentSet.Id)) { entities = entities.Where(en => en.DocumentSet.Id == request.DocumentSet.Id); } if (true == request.DocumentSetIds?.Any()) { entities = entities.Where(en => en.DocumentSet.Id.In(request.DocumentSetIds)); } if (!DocTools.IsNullOrEmpty(request.Name)) { entities = entities.Where(en => en.Name.Contains(request.Name)); } if (!DocTools.IsNullOrEmpty(request.Names)) { entities = entities.Where(en => en.Name.In(request.Names)); } if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id)) { entities = entities.Where(en => en.Owner.Id == request.Owner.Id); } if (true == request.OwnerIds?.Any()) { entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds)); } if (true == request.ScopesIds?.Any()) { entities = entities.Where(en => en.Scopes.Any(r => r.Id.In(request.ScopesIds))); } if (request.Status.HasValue) { entities = entities.Where(en => request.Status.Value == en.Status); } if (!DocTools.IsNullOrEmpty(request.Statuss)) { entities = entities.Where(en => en.Status.In(request.Statuss)); } if (true == request.TasksIds?.Any()) { entities = entities.Where(en => en.Tasks.Any(r => r.Id.In(request.TasksIds))); } if (request.Type.HasValue) { entities = entities.Where(en => request.Type.Value == en.Type); } if (!DocTools.IsNullOrEmpty(request.Types)) { entities = entities.Where(en => en.Type.In(request.Types)); } if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id)) { entities = entities.Where(en => en.User.Id == request.User.Id); } if (true == request.UserIds?.Any()) { entities = entities.Where(en => en.User.Id.In(request.UserIds)); } if (true == request.VariablesIds?.Any()) { entities = entities.Where(en => en.Variables.Any(r => r.Id.In(request.VariablesIds))); } if (true == request.WorkflowsIds?.Any()) { entities = entities.Where(en => en.Workflows.Any(r => r.Id.In(request.WorkflowsIds))); } entities = ApplyFilters <DocEntityWorkflow, WorkflowSearch>(request, entities); if (request.Skip > 0) { entities = entities.Skip(request.Skip.Value); } if (request.Take > 0) { entities = entities.Take(request.Take.Value); } if (true == request?.OrderBy?.Any()) { entities = entities.OrderBy(request.OrderBy); } if (true == request?.OrderByDesc?.Any()) { entities = entities.OrderByDescending(request.OrderByDesc); } }); return(entities); }
public object Post(WorkflowSearch request) => Get(request);