Example #1
0
        public ActionResult Config(string pageName, string queryId, string queryName)
        {
            var manager = new SavedTabQueryManager();
            ITabQuery query = null;
            SavedTabQuery savedQuery = null;

            if (!String.IsNullOrEmpty(queryId))
            {
                savedQuery = manager.Find(pageName, new Guid(queryId));
                query = TabQueries.GetQuery(savedQuery.QueryName);
                if (savedQuery.Config == null && query.ConfigType != null)
                {
                    savedQuery.Config = Activator.CreateInstance(query.ConfigType);
                }
            }
            else
            {
                query = TabQueries.GetQuery(queryName);
                savedQuery = new SavedTabQuery(queryName);
                if (query.ConfigType != null)
                {
                    savedQuery.Config = Activator.CreateInstance(query.ConfigType);
                }
            }

            ViewBag.Query = query;

            return PartialView(savedQuery);
        }
Example #2
0
        public ActionResult Config(string pageName, string queryName, string queryId, [ModelBinder(typeof(BindingTypeAwareModelBinder))]object config)
        {
            var manager = new SavedTabQueryManager();
            ITabQuery query = null;
            SavedTabQuery savedQuery = null;

            if (!String.IsNullOrEmpty(queryId))
            {
                savedQuery = manager.Find(pageName, new Guid(queryId));
                query = TabQueries.GetQuery(savedQuery.QueryName);
            }
            else
            {
                savedQuery = new SavedTabQuery(queryName);
                query = TabQueries.GetQuery(queryName);
            }

            savedQuery.DisplayName = Request.Form["DisplayName"];

            if (query.ConfigType != null)
            {
                savedQuery.Config = config;
            }

            if (!String.IsNullOrEmpty(queryId))
            {
                manager.Update(pageName, savedQuery);
            }
            else
            {
                manager.Add(pageName, savedQuery);
            }

            return Json(savedQuery);
        }
        public static TabQueryModel CreateTabQueryModel(this CommerceController controller, string pageName, ITabQuery defaultQuery, string defaultQueryDisplayName = "All")
        {
            var manager = new SavedTabQueryManager();

            var model = new TabQueryModel
            {
                PageName = pageName,
                SavedQueries = manager.FindAll(pageName).ToList(),
                AvailableQueries = TabQueries.GetQueries(controller.ControllerContext).ToList()
            };

            // Ensure default
            if (model.SavedQueries.Count == 0)
            {
                var savedQuery = SavedTabQuery.CreateFrom(defaultQuery, "All");
                manager.Add(model.PageName, savedQuery);
                model.SavedQueries.Add(savedQuery);
            }

            var queryId = controller.Request.QueryString["queryId"];

            if (String.IsNullOrEmpty(queryId))
            {
                model.CurrentQuery = model.SavedQueries.FirstOrDefault();
            }
            else
            {
                model.CurrentQuery = manager.Find(model.PageName, new Guid(queryId));
            }

            var query = model.AvailableQueries.Find(q => q.Name == model.CurrentQuery.QueryName);

            var search = controller.Request.QueryString["search"];
            var page = 1;
            if (!String.IsNullOrEmpty(controller.Request.QueryString["page"]))
            {
                page = Convert.ToInt32(controller.Request.QueryString["page"]);
            }

            var pageSize = 50;
            if (!String.IsNullOrEmpty(controller.Request.QueryString["pageSize"]))
            {
                pageSize = Convert.ToInt32(controller.Request.QueryString["pageSize"]);
            }

            model.CurrentQueryResult = query.Execute(new QueryContext(controller.CurrentInstance, search, page - 1, pageSize, model.CurrentQuery.Config))
                                            .ToPagedList();

            return model;
        }
Example #4
0
 public void SaveOrders(string pageName, SavedTabQuery[] models)
 {
     var manager = new SavedTabQueryManager();
     foreach (var model in models)
     {
         var query = manager.Find(pageName, model.Id);
         query.Order = model.Order;
         manager.Update(pageName, query);
     }
 }
Example #5
0
 public void Delete(string pageName, Guid queryId)
 {
     var manager = new SavedTabQueryManager();
     manager.Delete(pageName, queryId);
 }