Exemple #1
0
        protected internal virtual Lite <Entity> FindUnique(UniqueOptions options)
        {
            var queryDescription = DynamicQueryManager.Current.QueryDescription(options.QueryName);

            FilterOption.SetFilterTokens(options.FilterOptions, queryDescription, canAggregate: false);
            OrderOption.SetOrderTokens(options.OrderOptions, queryDescription, canAggregate: false);

            var request = new UniqueEntityRequest
            {
                QueryName  = options.QueryName,
                Filters    = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders     = options.OrderOptions.Select(o => o.ToOrder()).ToList(),
                UniqueType = options.UniqueType,
            };

            return(DynamicQueryManager.Current.ExecuteUniqueEntity(request));
        }
Exemple #2
0
        public static MvcHtmlString SearchControl(this HtmlHelper helper, FindOptions findOptions, Context context, Action <SearchControl> settingsModifier)
        {
            var options = new SearchControl {
                Prefix = context.Prefix
            };

            if (settingsModifier != null)
            {
                settingsModifier(options);
            }

            QueryDescription description = DynamicQueryManager.Current.QueryDescription(findOptions.QueryName);

            FilterOption.SetFilterTokens(findOptions.FilterOptions, description, false);
            OrderOption.SetOrderTokens(findOptions.OrderOptions, description, false);
            ColumnOption.SetColumnTokens(findOptions.ColumnOptions, description, false);
            Finder.Manager.SetSearchViewableAndCreable(findOptions, description);
            FinderManager.SetDefaultOrder(findOptions, description);

            var viewData = new ViewDataDictionary(context);

            viewData[ViewDataKeys.FindOptions]      = findOptions;
            viewData[ViewDataKeys.QueryDescription] = DynamicQueryManager.Current.QueryDescription(findOptions.QueryName);

            viewData[ViewDataKeys.Title] = helper.ViewData.ContainsKey(ViewDataKeys.Title) ?
                                           helper.ViewData[ViewDataKeys.Title] : QueryUtils.GetNiceName(findOptions.QueryName);

            if (!options.ToolBarButton.IsNullOrEmpty())
            {
                viewData[ViewDataKeys.ManualToolbarButtons] = options.ToolBarButton;
            }

            if (options.AvoidFullScreenButton)
            {
                viewData[ViewDataKeys.AvoidFullScreenButton] = true;
            }

            return(helper.Partial(Finder.Manager.SearchControlView, viewData));
        }