protected virtual void PrepareCategoryModel(CategoryModel model) { if (model == null) { throw new ArgumentNullException("model"); } model.AvailableCategories.Add(new SelectListItem { Text = "顶级类别", Value = "0", Selected = model.ParentId == 0 }); var allCategories = SelectListHelper.GetCategoryList(_categoryService, true); foreach (var c in allCategories) { c.Selected = model.ParentId.ToString() == c.Value; model.AvailableCategories.Add(c); } if (model.Id == 0) { model.DisplayOrder = 999; } }
public ActionResult MyItems() { if (!_workContext.CurrentUser.IsRegistered()) { return(new HttpUnauthorizedResult()); } var model = new ItemListModel(); // категории model.AvailableCategories.Add(new SelectListItem { Text = "Все", Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } // типы товаров model.AvailableItemTypes = ItemType.ShopItem.ToSelectList(false).ToList(); model.AvailableItemTypes.Insert(0, new SelectListItem { Text = "Все", Value = "0" }); return(View(model)); }
public HttpResponseMessage ProductAddPopupData(HttpRequestMessage request, int categoryId) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; var model = new CategoryVM.AddCategoryProductVM(); string allString = _localizationService.GetResource("Admin.Common.All"); //categories model.AvailableCategories.Add(new System.Web.Mvc.SelectListItem { Text = allString, Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _languageService, _localizedEntityService, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //manufacturers model.AvailableManufacturers.Add(new System.Web.Mvc.SelectListItem { Text = allString, Value = "0" }); var manufacturers = SelectListHelper.GetManufacturerList(_manufacturerService, true); foreach (var m in manufacturers) { model.AvailableManufacturers.Add(m); } //stores model.AvailableStores.Add(new System.Web.Mvc.SelectListItem { Text = allString, Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new System.Web.Mvc.SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //vendors model.AvailableVendors.Add(new System.Web.Mvc.SelectListItem { Text = allString, Value = "0" }); var vendors = SelectListHelper.GetVendorList(_vendorService, true); foreach (var v in vendors) { model.AvailableVendors.Add(v); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(_localizationService, _baseService.WorkContext, false).ToList(); model.AvailableProductTypes.Insert(0, new System.Web.Mvc.SelectListItem { Text = allString, Value = "0" }); response = request.CreateResponse <CategoryVM.AddCategoryProductVM>(HttpStatusCode.Created, model); return response; })); }
public ActionResult CallApi() { var model = new ConfigurationModel(); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategory.Add(c); } return(View("~/Plugins/Affiliate.Ebay/Views/CallApi.cshtml", model)); }
protected virtual void PrepareBlogListModel(BlogListModel model) { if (model == null) { throw new ArgumentNullException("model"); } var allCategories = SelectListHelper.GetCategoryList(_categoryService, true); foreach (var c in allCategories) { c.Selected = model.SearchCategories.Contains(int.Parse(c.Value)); model.AvailableCategories.Add(c); } }
/// <summary> /// Prepare available categories /// </summary> /// <param name="items">Category items</param> /// <param name="withSpecialDefaultItem">Whether to insert the first special item for the default value</param> /// <param name="defaultItemText">Default item text; pass null to use default value of the default item text</param> public virtual void PrepareCategories(IList <SelectListItem> items, bool withSpecialDefaultItem = true, string defaultItemText = null) { if (items == null) { throw new ArgumentNullException(nameof(items)); } //prepare available categories var availableCategoryItems = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var categoryItem in availableCategoryItems) { items.Add(categoryItem); } //insert special item for the default value PrepareDefaultItem(items, withSpecialDefaultItem, defaultItemText); }
protected virtual void PrepareAllCategoriesModel(CategoryModel model) { if (model == null) { throw new ArgumentNullException("model"); } model.AvailableCategories.Add(new SelectListItem { Text = "[None]", Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } }
protected virtual void PrepareAllCategoriesModel(CategoryModel model) { if (model == null) { throw new ArgumentNullException("model"); } model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Categories.Fields.Parent.None"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } }
protected virtual void PrepareCategoryMappingModel(ItemModel model, Item item) { if (model == null) { throw new ArgumentNullException("model"); } if (item != null) { model.SelectedCategoryIds = _categoryService.GetItemCategoriesByItemId(item.Id, true).Select(c => c.CategoryId).ToList(); } var allCategories = SelectListHelper.GetCategoryList(_categoryService, true); foreach (var c in allCategories) { c.Selected = model.SelectedCategoryIds.Contains(int.Parse(c.Value)); model.AvailableCategories.Add(c); } }
protected virtual void PreparePostModel(PostModel model) { if (model == null) { throw new ArgumentNullException("model"); } var allCategories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in allCategories) { model.AvailableCategories.Add(c); } model.AvailableCategories.Insert(0, new SelectListItem { Text = "选择分类", Value = "0" }); }
protected virtual void PrepareCategoryModel(CategoryModel model) { if (model == null) { throw new ArgumentNullException("model"); } var allCategories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in allCategories) { c.Selected = model.SelectedCategoryIds.Contains(int.Parse(c.Value)); model.AvailableCategories.Add(c); } model.AvailableCategories.Insert(0, new SelectListItem { Text = "顶级类别", Value = "0", Selected = model.ParentCategoryId == 0 }); }
protected virtual void PrepareProductCategoriesModel(ProductViewModel model) { if (model == null) { throw new ArgumentNullException("model"); } if (model.CategoryList == null) { model.CategoryList = new List <SelectListItem>(); } model.CategoryList.Add(new SelectListItem { Text = "Please choose a category", Value = "" }); var categories = SelectListHelper.GetCategoryList(_productCategoryService); foreach (var c in categories) { model.CategoryList.Add(c); } }
public virtual ActionResult ProductAddPopup(int categoryId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) { return(AccessDeniedView()); } var model = new CategoryModel.AddCategoryProductModel(); //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return(View(model)); }
public ActionResult ProductAddPopup(int discountId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts)) { return(AccessDeniedView()); } var model = new DiscountModel.AddProductToDiscountModel(); //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //manufacturers model.AvailableManufacturers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var m in _manufacturerService.GetAllManufacturers(showHidden: true)) { model.AvailableManufacturers.Add(new SelectListItem { Text = m.Name, Value = m.Id.ToString() }); } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //vendors model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var v in _vendorService.GetAllVendors(showHidden: true)) { model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id.ToString() }); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return(View(model)); }
public IActionResult ProductAddPopupList() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts) && !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord)) { return(AccessDeniedView()); } var model = new AddOfferTypeModel(); //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //manufacturers model.AvailableManufacturers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var manufacturers = SelectListHelper.GetManufacturerList(_manufacturerService, _cacheManager, true); foreach (var m in manufacturers) { model.AvailableManufacturers.Add(m); } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //vendors model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var vendors = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true); foreach (var v in vendors) { model.AvailableVendors.Add(v); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return(View("~/Plugins/Progressive.Web.App/Views/ProductAddPopup.cshtml", model)); }
public virtual ActionResult ArticleAddPopup(int publisherId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePublishers)) { return(AccessDeniedView()); } var model = new PublisherModel.AddPublisherArticleModel(); //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //publishers model.AvailablePublishers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var publishers = SelectListHelper.GetPublisherList(_publisherService, _cacheManager, true); foreach (var m in publishers) { model.AvailablePublishers.Add(m); } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //contributors model.AvailableContributors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var contributors = SelectListHelper.GetContributorList(_contributorService, _cacheManager, true); foreach (var v in contributors) { model.AvailableContributors.Add(v); } //article types model.AvailableArticleTypes = ArticleType.SimpleArticle.ToSelectList(false).ToList(); model.AvailableArticleTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return(View(model)); }
public virtual ActionResult AssociateProductToCustomerRolePopup() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) { return(AccessDeniedView()); } var model = new CustomerRoleModel.AssociateProductToCustomerRoleModel(); //a vendor should have access only to his products model.IsLoggedInAsVendor = _workContext.CurrentVendor != null; //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //destinations model.AvailableDestinations.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var destinations = SelectListHelper.GetDestinationList(_destinationService, _cacheManager, true); foreach (var m in destinations) { model.AvailableDestinations.Add(m); } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //vendors model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var vendors = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true); foreach (var v in vendors) { model.AvailableVendors.Add(v); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return(View(model)); }
public virtual ActionResult ProductAddPopup(int manufacturerId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageManufacturers)) { return(AccessDeniedView()); } var model = new ManufacturerModel.AddManufacturerProductModel(); //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //manufacturers model.AvailableManufacturers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var manufacturers = SelectListHelper.GetManufacturerList(_manufacturerService, _cacheManager, true); foreach (var m in manufacturers) { model.AvailableManufacturers.Add(m); } #region Extensions by QuanNH //stores var _workContext = Nop.Core.Infrastructure.EngineContext.Current.Resolve <Nop.Core.IWorkContext>(); var AllStores = _storeService.GetAllStoresByEntityName(_workContext.CurrentCustomer.Id, "Stores"); if (AllStores.Count <= 0) { AllStores = _storeService.GetAllStores(); model.AvailableStores.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); } foreach (var s in AllStores) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } #endregion //vendors model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var vendors = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true); foreach (var v in vendors) { model.AvailableVendors.Add(v); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return(View(model)); }
public IActionResult Configure() { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(AccessDeniedView()); } var model = new FeedGoogleShoppingModel(); model.ProductPictureSize = _googleShoppingSettings.ProductPictureSize; model.PassShippingInfoWeight = _googleShoppingSettings.PassShippingInfoWeight; model.PassShippingInfoDimensions = _googleShoppingSettings.PassShippingInfoDimensions; model.PricesConsiderPromotions = _googleShoppingSettings.PricesConsiderPromotions; //stores model.StoreId = _googleShoppingSettings.StoreId; model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //currencies model.CurrencyId = _googleShoppingSettings.CurrencyId; foreach (var c in _currencyService.GetAllCurrencies()) { model.AvailableCurrencies.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString() }); } //Google categories model.DefaultGoogleCategory = _googleShoppingSettings.DefaultGoogleCategory; model.AvailableGoogleCategories.Add(new SelectListItem { Text = "Select a category", Value = "" }); foreach (var gc in _googleService.GetTaxonomyList()) { model.AvailableGoogleCategories.Add(new SelectListItem { Text = gc, Value = gc }); } model.SelectedCategoryIds = !string.IsNullOrEmpty(_googleShoppingSettings.SelectedCategoryIds) && _googleShoppingSettings.SelectedCategoryIds.Split(',').Count() > 0 ? _googleShoppingSettings.SelectedCategoryIds.Split(',').Select(c => int.Parse(c)).ToList() : new List <int>(); var categoryService = EngineContext.Current.Resolve <ICategoryService>(); var cacheManager = EngineContext.Current.Resolve <ICacheManager>(); var allCategories = SelectListHelper.GetCategoryList(categoryService, cacheManager, true); foreach (var c in allCategories) { c.Selected = model.SelectedCategoryIds.Contains(int.Parse(c.Value)); model.AvailableCategories.Add(c); } //file paths foreach (var store in _storeService.GetAllStores()) { var localFilePath = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "files\\exportimport", store.Id + "-" + _googleShoppingSettings.StaticFileName); if (System.IO.File.Exists(localFilePath)) { model.GeneratedFiles.Add(new FeedGoogleShoppingModel.GeneratedFileModel { StoreName = store.Name, FileUrl = $"{_webHelper.GetStoreLocation(false)}files/exportimport/{store.Id}-{_googleShoppingSettings.StaticFileName}" }); } } return(View("~/Plugins/Feed.GoogleShopping/Views/Configure.cshtml", model)); }
public virtual IActionResult List(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) { return(AccessDeniedView()); } var itemName = _productService.GetProductById(id).Name; var model = new ProductListModel { //a vendor should have access only to his products IsLoggedInAsVendor = _workContext.CurrentVendor != null, AllowVendorsToImportProducts = _vendorSettings.AllowVendorsToImportProducts, ItemId = id, ItemName = itemName, BelongsTo = true, SingleType = true, }; //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true); foreach (var c in categories) { model.AvailableCategories.Add(c); } //manufacturers model.AvailableManufacturers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var manufacturers = SelectListHelper.GetManufacturerList(_manufacturerService, _cacheManager, true); foreach (var m in manufacturers) { model.AvailableManufacturers.Add(m); } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } //warehouses model.AvailableWarehouses.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var wh in _shippingService.GetAllWarehouses()) { model.AvailableWarehouses.Add(new SelectListItem { Text = wh.Name, Value = wh.Id.ToString() }); } //vendors model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var vendors = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true); foreach (var v in vendors) { model.AvailableVendors.Add(v); } //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //"published" property //0 - all (according to "ShowHidden" parameter) //1 - published only //2 - unpublished only model.AvailablePublishedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Products.List.SearchPublished.All"), Value = "0" }); model.AvailablePublishedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Products.List.SearchPublished.PublishedOnly"), Value = "1" }); model.AvailablePublishedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Products.List.SearchPublished.UnpublishedOnly"), Value = "2" }); return(View("~/Plugins/Misc.ProductWizard/Views/Relations/List.cshtml", model)); //return View("~/Plugins/Misc.ProductWizard/Views/Relations/List.cshtml", model); }