Пример #1
0
        public void Delete(GlossarySearch request)
        {
            var matches = Get(request) as List <Glossary>;

            if (true != matches?.Any())
            {
                throw new HttpError(HttpStatusCode.NotFound, "No matches for request");
            }
            matches.ForEach(match =>
            {
                Delete(match);
            });
        }
Пример #2
0
 public object Get(GlossarySearch request) => GetSearchResultWithCache <Glossary, DocEntityGlossary, GlossarySearch>(DocConstantModelName.GLOSSARY, request, _ExecSearch);
Пример #3
0
        private IQueryable <DocEntityGlossary> _ExecSearch(GlossarySearch request, DocQuery query)
        {
            request = InitSearch <Glossary, GlossarySearch>(request);
            IQueryable <DocEntityGlossary> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityGlossary>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new GlossaryFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityGlossary, GlossaryFullTextSearch>(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.GLOSSARY, 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.Definition))
                {
                    entities = entities.Where(en => en.Definition.Contains(request.Definition));
                }
                if (!DocTools.IsNullOrEmpty(request.Definitions))
                {
                    entities = entities.Where(en => en.Definition.In(request.Definitions));
                }
                if (!DocTools.IsNullOrEmpty(request.Enum) && !DocTools.IsNullOrEmpty(request.Enum.Id))
                {
                    entities = entities.Where(en => en.Enum.Id == request.Enum.Id);
                }
                if (true == request.EnumIds?.Any())
                {
                    entities = entities.Where(en => en.Enum.Id.In(request.EnumIds));
                }
                if (true == request.EnumNames?.Any())
                {
                    entities = entities.Where(en => en.Enum.Name.In(request.EnumNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Icon))
                {
                    entities = entities.Where(en => en.Icon.Contains(request.Icon));
                }
                if (!DocTools.IsNullOrEmpty(request.Icons))
                {
                    entities = entities.Where(en => en.Icon.In(request.Icons));
                }
                if (!DocTools.IsNullOrEmpty(request.Page) && !DocTools.IsNullOrEmpty(request.Page.Id))
                {
                    entities = entities.Where(en => en.Page.Id == request.Page.Id);
                }
                if (true == request.PageIds?.Any())
                {
                    entities = entities.Where(en => en.Page.Id.In(request.PageIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Term) && !DocTools.IsNullOrEmpty(request.Term.Id))
                {
                    entities = entities.Where(en => en.Term.Id == request.Term.Id);
                }
                if (true == request.TermIds?.Any())
                {
                    entities = entities.Where(en => en.Term.Id.In(request.TermIds));
                }

                entities = ApplyFilters <DocEntityGlossary, GlossarySearch>(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);
        }
Пример #4
0
 public object Post(GlossarySearch request) => Get(request);