public IEnumerable <Lite <UserQueryEntity> > FromQuery(string queryKey)
 {
     return(UserQueryLogic.GetUserQueries(QueryLogic.ToQueryName(queryKey)));
 }
 public IEnumerable <Lite <UserQueryEntity> > FromQueryAppendFilters(string queryKey)
 {
     return(UserQueryLogic.GetUserQueries(QueryLogic.ToQueryName(queryKey), appendFilterOnly: true));
 }
示例#3
0
        static ToolBarButton[] ButtonBarQueryHelper_GetButtonBarForQueryName(QueryButtonContext ctx)
        {
            if (ctx.Prefix.HasText())
            {
                return(null);
            }

            if (!Navigator.IsNavigable(typeof(UserQueryEntity), null, isSearch: true))
            {
                return(null);
            }

            var items = new List <IMenuItem>();

            Lite <UserQueryEntity> currentUserQuery = null;
            string url = (ctx.ControllerContext.RouteData.Route as Route)?.Url;

            if (url.HasText() && url.Contains("UQ"))
            {
                currentUserQuery = Lite.Create <UserQueryEntity>(PrimaryKey.Parse(ctx.ControllerContext.RouteData.Values["lite"].ToString(), typeof(UserQueryEntity)));
            }

            foreach (var uq in UserQueryLogic.GetUserQueries(ctx.QueryName).OrderBy(a => a.ToString()))
            {
                items.Add(new MenuItem(ctx.Prefix, "sfUserQuery" + uq.Id)
                {
                    Text     = uq.ToString(),
                    Title    = uq.ToString(),
                    Href     = RouteHelper.New().Action <UserQueriesController>(uqc => uqc.View(uq, null, null)),
                    CssClass = "sf-userquery" + (currentUserQuery.Is(uq) ? " sf-userquery-selected" : "")
                });
            }

            if (items.Count > 0)
            {
                items.Add(new MenuItemSeparator());
            }

            if (Navigator.IsCreable(typeof(UserQueryEntity), isSearch: null))
            {
                items.Add(new MenuItem(ctx.Prefix, "qbUserQueryNew")
                {
                    Title   = UserQueryMessage.UserQueries_CreateNew.NiceToString(),
                    Text    = UserQueryMessage.UserQueries_CreateNew.NiceToString(),
                    OnClick = Module["createUserQuery"](ctx.Prefix, ctx.Url.Action("Create", "UserQueries"))
                });
            }

            if (currentUserQuery != null && currentUserQuery.IsAllowedFor(TypeAllowedBasic.Modify, inUserInterface: true))
            {
                items.Add(new MenuItem(ctx.Prefix, "qbUserQueryEdit")
                {
                    Title = UserQueryMessage.UserQueries_Edit.NiceToString(),
                    Text  = UserQueryMessage.UserQueries_Edit.NiceToString(),
                    Href  = Navigator.NavigateRoute(currentUserQuery)
                });
            }

            string uqUserQueriesText = UserQueryMessage.UserQueries_UserQueries.NiceToString();

            return(new ToolBarButton[]
            {
                new ToolBarDropDown(ctx.Prefix, "tmUserQueries")
                {
                    Title = uqUserQueriesText,
                    Text = uqUserQueriesText,
                    Items = items
                }
            });
        }