Beispiel #1
0
        public List<Lite<WordTemplateEntity>> GetWordTemplates(string queryKey, WordTemplateVisibleOn visibleOn, [Required, FromBody]GetWordTemplatesRequest request)
        {
            object type = QueryLogic.ToQueryName(queryKey);

            var entity = request.lite?.RetrieveAndForget();

            return WordTemplateLogic.GetApplicableWordTemplates(type, entity, visibleOn);
        }
Beispiel #2
0
        public List <Lite <WordTemplateEntity> > GetWordTemplates(string queryKey, WordTemplateVisibleOn visibleOn, Lite <Entity> lite)
        {
            object type = QueryLogic.ToQueryName(queryKey);

            var entity = lite?.RetrieveAndForget();

            return(WordTemplateLogic.GetApplicableWordTemplates(type, entity, visibleOn));
        }
        public static bool IsVisible(WordTemplateEntity wt, WordTemplateVisibleOn visibleOn)
        {
            if (wt.SystemWordTemplate == null)
            {
                return(visibleOn == WordTemplateVisibleOn.Single);
            }

            if (SystemWordTemplateLogic.HasDefaultTemplateConstructor(wt.SystemWordTemplate))
            {
                return(false);
            }

            var entityType = SystemWordTemplateLogic.GetEntityType(wt.SystemWordTemplate.ToType());

            if (entityType.IsEntity())
            {
                return(visibleOn == WordTemplateVisibleOn.Single);
            }

            var should = VisibleOnDictionary.TryGet(entityType, WordTemplateVisibleOn.Single);

            return((should & visibleOn) != 0);
        }
        public static List <Lite <WordTemplateEntity> > GetApplicableWordTemplates(object queryName, Entity entity, WordTemplateVisibleOn visibleOn)
        {
            var isAllowed = Schema.Current.GetInMemoryFilter <WordTemplateEntity>(userInterface: true);

            return(TemplatesByQueryName.Value.TryGetC(queryName).EmptyIfNull()
                   .Where(a => isAllowed(a) && IsVisible(a, visibleOn))
                   .Where(a => a.IsApplicable(entity))
                   .Select(a => a.ToLite())
                   .ToList());
        }