Example #1
0
        public void Delete(ScopeSearch request)
        {
            var matches = Get(request) as List <Scope>;

            if (true != matches?.Any())
            {
                throw new HttpError(HttpStatusCode.NotFound, "No matches for request");
            }
            matches.ForEach(match =>
            {
                Delete(match);
            });
        }
Example #2
0
 public object Get(ScopeSearch request) => GetSearchResultWithCache <Scope, DocEntityScope, ScopeSearch>(DocConstantModelName.SCOPE, request, _ExecSearch);
Example #3
0
        private IQueryable <DocEntityScope> _ExecSearch(ScopeSearch request, DocQuery query)
        {
            request = InitSearch <Scope, ScopeSearch>(request);
            IQueryable <DocEntityScope> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityScope>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new ScopeFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityScope, ScopeFullTextSearch>(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.SCOPE, 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 (!DocTools.IsNullOrEmpty(request.App) && !DocTools.IsNullOrEmpty(request.App.Id))
                {
                    entities = entities.Where(en => en.App.Id == request.App.Id);
                }
                if (true == request.AppIds?.Any())
                {
                    entities = entities.Where(en => en.App.Id.In(request.AppIds));
                }
                if (true == request.BindingsIds?.Any())
                {
                    entities = entities.Where(en => en.Bindings.Any(r => r.Id.In(request.BindingsIds)));
                }
                if (true == request.BroadcastsIds?.Any())
                {
                    entities = entities.Where(en => en.Broadcasts.Any(r => r.Id.In(request.BroadcastsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Client) && !DocTools.IsNullOrEmpty(request.Client.Id))
                {
                    entities = entities.Where(en => en.Client.Id == request.Client.Id);
                }
                if (true == request.ClientIds?.Any())
                {
                    entities = entities.Where(en => en.Client.Id.In(request.ClientIds));
                }
                if (true == request.Delete?.Any())
                {
                    entities = entities.Where(en => en.Delete.In(request.Delete));
                }
                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 (true == request.Edit?.Any())
                {
                    entities = entities.Where(en => en.Edit.In(request.Edit));
                }
                if (true == request.HelpIds?.Any())
                {
                    entities = entities.Where(en => en.Help.Any(r => r.Id.In(request.HelpIds)));
                }
                if (true == request.IsGlobal?.Any())
                {
                    entities = entities.Where(en => en.IsGlobal.In(request.IsGlobal));
                }
                if (true == request.ScopedCommentsIds?.Any())
                {
                    entities = entities.Where(en => en.ScopedComments.Any(r => r.Id.In(request.ScopedCommentsIds)));
                }
                if (true == request.ScopedFilesIds?.Any())
                {
                    entities = entities.Where(en => en.ScopedFiles.Any(r => r.Id.In(request.ScopedFilesIds)));
                }
                if (true == request.ScopedTagsIds?.Any())
                {
                    entities = entities.Where(en => en.ScopedTags.Any(r => r.Id.In(request.ScopedTagsIds)));
                }
                if (true == request.SynonymsIds?.Any())
                {
                    entities = entities.Where(en => en.Synonyms.Any(r => r.Id.In(request.SynonymsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Team) && !DocTools.IsNullOrEmpty(request.Team.Id))
                {
                    entities = entities.Where(en => en.Team.Id == request.Team.Id);
                }
                if (true == request.TeamIds?.Any())
                {
                    entities = entities.Where(en => en.Team.Id.In(request.TeamIds));
                }
                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.VariableRulesIds?.Any())
                {
                    entities = entities.Where(en => en.VariableRules.Any(r => r.Id.In(request.VariableRulesIds)));
                }
                if (true == request.View?.Any())
                {
                    entities = entities.Where(en => en.View.In(request.View));
                }
                if (true == request.WorkflowsIds?.Any())
                {
                    entities = entities.Where(en => en.Workflows.Any(r => r.Id.In(request.WorkflowsIds)));
                }

                entities = ApplyFilters <DocEntityScope, ScopeSearch>(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);
        }
Example #4
0
 public object Post(ScopeSearch request) => Get(request);