예제 #1
0
        private void FillListControls()
        {
            RoleController  roleController = new RoleController();
            List <RoleInfo> roleInfos      = roleController.GetPortalRoles(PortalId).ToList <RoleInfo>();

            ddlDnnRole.DataSource     = roleInfos;
            ddlDnnRole.DataValueField = "RoleID";
            ddlDnnRole.DataTextField  = "RoleName";
            ddlDnnRole.DataBind();
            ddlDnnRole.Items.Insert(0, new ListItem()
            {
                Value = "-1", Text = "All Users"
            });
            ddlDnnRole.Items.Insert(0, "");

            List <Product> products = ProductCollection.GetAll(StoreContext.CurrentStore.Id.Value);

            chkAppliesToProducts.DataSource     = products;
            chkAppliesToProducts.DataValueField = ProductMetadata.PropertyNames.Id;
            chkAppliesToProducts.DataTextField  = ProductMetadata.PropertyNames.Name;
            chkAppliesToProducts.DataBind();

            List <Category> categories = CategoryCollection.GetCategoryList(StoreContext.CurrentStore.Id.Value, true);

            chkAppliesToCategories.Items.Clear();
            foreach (var c in categories)
            {
                string indent = "...".Repeat(c.NestingLevel.GetValueOrDefault(0));
                chkAppliesToCategories.Items.Add(new ListItem()
                {
                    Value = c.Id.ToString(), Text = indent + c.Name
                });
            }
        }
예제 #2
0
        public override void LoadSettings()
        {
            if (!IsPostBack)
            {
                DataModel.DataModel.Initialize();

                var store = StoreContext.GetCurrentStore(HttpContext.Current.Request);

                string sortByValue  = Convert.ToString(ModuleSettings[FeaturedSettings.SortBy]) ?? "Name-ASC";
                var    sortByFields = Product.GetSortByFields();
                ddlSortBy.Items.Clear();
                foreach (var f in sortByFields)
                {
                    ddlSortBy.Items.Add(new ListItem()
                    {
                        Value = f.GetValueString(), Text = f.DisplayName, Selected = f.GetValueString() == sortByValue
                    });
                }

                //txtProductsPerPage.Text = WA.Parser.ToInt(ModuleSettings[FeaturedSettings.ProductsPerPage]).GetValueOrDefault(100).ToString();
                txtMaxProducts.Text = WA.Parser.ToInt(ModuleSettings[FeaturedSettings.MaxNumProducts]).GetValueOrDefault(25).ToString();

                rdoCategoryFilterMethod.TrySetSelectedValue(Convert.ToString(ModuleSettings[FeaturedSettings.CategoryFilterMethod]));

                var allCategories       = CategoryCollection.GetCategoryList(store.Id.Value, true);
                var selectedCategoryIds = (Convert.ToString(ModuleSettings[FeaturedSettings.CategoryFilterCategoryIds]) ?? string.Empty).Split(',').Select(WA.Parser.ToInt).ToList();
                chkCategoryIds.Items.Clear();
                foreach (var cat in allCategories)
                {
                    string indent = "...".Repeat(cat.NestingLevel.GetValueOrDefault(0));
                    chkCategoryIds.Items.Add(new ListItem()
                    {
                        Value = cat.Id.Value.ToString(), Text = indent + cat.Name, Selected = selectedCategoryIds.Contains(cat.Id)
                    });
                }

                // Templates
                txtTemplateHeader.Text    = ModuleSettings[FeaturedSettings.TemplateHeader] != null ? ModuleSettings[FeaturedSettings.TemplateHeader].ToString() : FeaturedSettings.DefaultHeader;
                txtTemplateProduct.Text   = ModuleSettings[FeaturedSettings.TemplateProduct] != null ? ModuleSettings[FeaturedSettings.TemplateProduct].ToString() : FeaturedSettings.DefaultProduct;
                txtTemplateFooter.Text    = ModuleSettings[FeaturedSettings.TemplateFooter] != null ? ModuleSettings[FeaturedSettings.TemplateFooter].ToString() : FeaturedSettings.DefaultFooter;
                txtTemplateNoResults.Text = ModuleSettings[FeaturedSettings.TemplateNoResults] != null ? ModuleSettings[FeaturedSettings.TemplateNoResults].ToString() : FeaturedSettings.DefaultNoResults;
            }
        }
예제 #3
0
        private void PopulateListControls()
        {
            List <Category> parentCategories = CategoryCollection.GetCategoryList(StoreContext.CurrentStore.Id.GetValueOrDefault(-1), true);

            if (isEditMode)
            {
                // remove myself from the parent category list
                parentCategories.RemoveAll(c => c.Id.Value == category.Id.Value);

                // remove my descendant categories from the list
                parentCategories.RemoveAll(c => c.IsDescendantOf(category));
            }

            ddlParentId.Items.Clear();
            ddlParentId.Items.AddRange(parentCategories.ConvertAll(c => new ListItem("....".Repeat(c.GetNestingLevel()) + c.Name, c.Id.Value.ToString())).ToArray());
            ddlParentId.Items.Insert(0, new ListItem(" - none - ", ""));

            // set my parent category as selected
            if (isEditMode && category.ParentId.HasValue)
            {
                ddlParentId.TrySetSelectedValue(category.ParentId.Value.ToString());
            }
        }