Exemple #1
0
        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;
            }));
        }
        /// <summary>
        /// Prepare available vendors
        /// </summary>
        /// <param name="items">Vendor 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 PrepareVendors(IList <SelectListItem> items, bool withSpecialDefaultItem = true, string defaultItemText = null)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            //prepare available vendors
            var availableVendorItems = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true);

            foreach (var vendorItem in availableVendorItems)
            {
                items.Add(vendorItem);
            }

            //insert special item for the default value
            PrepareDefaultItem(items, withSpecialDefaultItem, defaultItemText);
        }
Exemple #3
0
        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);
            }

            //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(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
                });
            }
            //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);
            }
            //file paths
            foreach (var store in _storeService.GetAllStores())
            {
                var localFilePath  = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "files\\exportimport", store.Id + "-cimri-" + _googleShoppingSettings.StaticFileName);
                var localFilePaths = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "files\\exportimport",
                                                            store.Id + "-google-" + _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}-cimri-{_googleShoppingSettings.StaticFileName}"
                    });
                }
                if (System.IO.File.Exists(localFilePaths))
                {
                    model.GeneratedFiles.Add(new FeedGoogleShoppingModel.GeneratedFileModel
                    {
                        StoreName = store.Name,
                        FileUrl   = $"{_webHelper.GetStoreLocation(false)}files/exportimport/{store.Id}-google-{_googleShoppingSettings.StaticFileName}"
                    });
                }
            }

            return(View("~/Plugins/Feed.GoogleShopping/Views/Configure.cshtml", model));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        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);
        }
        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 virtual ActionResult List(
            [ModelBinder(typeof(CommaSeparatedModelBinder))] List<string> orderStatusIds = null,
            [ModelBinder(typeof(CommaSeparatedModelBinder))] List<string> paymentStatusIds = null,
            [ModelBinder(typeof(CommaSeparatedModelBinder))] List<string> shippingStatusIds = null)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedView();

            //order statuses
            var model = new Admin.Models.Orders.OrderListModel();
            model.AvailableOrderStatuses = OrderStatus.Pending.ToSelectList(false).ToList();
            model.AvailableOrderStatuses.Insert(0, new SelectListItem
            { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0", Selected = true });
            if (orderStatusIds != null && orderStatusIds.Any())
            {
                foreach (var item in model.AvailableOrderStatuses.Where(os => orderStatusIds.Contains(os.Value)))
                    item.Selected = true;
                model.AvailableOrderStatuses.First().Selected = false;
            }
            //payment statuses
            model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(false).ToList();
            model.AvailablePaymentStatuses.Insert(0, new SelectListItem
            { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0", Selected = true });
            if (paymentStatusIds != null && paymentStatusIds.Any())
            {
                foreach (var item in model.AvailablePaymentStatuses.Where(ps => paymentStatusIds.Contains(ps.Value)))
                    item.Selected = true;
                model.AvailablePaymentStatuses.First().Selected = false;
            }

            //shipping statuses
            model.AvailableShippingStatuses = ShippingStatus.NotYetShipped.ToSelectList(false).ToList();
            model.AvailableShippingStatuses.Insert(0, new SelectListItem
            { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0", Selected = true });
            if (shippingStatusIds != null && shippingStatusIds.Any())
            {
                foreach (var item in model.AvailableShippingStatuses.Where(ss => shippingStatusIds.Contains(ss.Value)))
                    item.Selected = true;
                model.AvailableShippingStatuses.First().Selected = false;
            }

            //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);

            //warehouses
            model.AvailableWarehouses.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            foreach (var w in _shippingService.GetAllWarehouses())
                model.AvailableWarehouses.Add(new SelectListItem { Text = w.Name, Value = w.Id.ToString() });

            //payment methods
            model.AvailablePaymentMethods.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "" });
            foreach (var pm in _paymentService.LoadAllPaymentMethods())
                model.AvailablePaymentMethods.Add(new SelectListItem { Text = pm.PluginDescriptor.FriendlyName, Value = pm.PluginDescriptor.SystemName });

            //billing countries
            foreach (var c in _countryService.GetAllCountriesForBilling(showHidden: true))
            {
                model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString() });
            }
            model.AvailableCountries.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });

            //a vendor should have access only to orders with his products
            model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;

            return View("~/Plugins/Order.Amazon/Views/List.cshtml", model);
        }