Ejemplo n.º 1
0
        public virtual ActionResult ProductAddPopupList(DataSourceRequest command, DestinationModel.AddDestinationProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDestinations))
            {
                return(AccessDeniedKendoGridJson());
            }

            var gridModel = new DataSourceResult();
            var products  = _productService.SearchProducts(
                categoryIds: new List <int> {
                model.SearchCategoryId
            },
                destinationId: model.SearchDestinationId,
                storeId: model.SearchStoreId,
                vendorId: model.SearchVendorId,
                productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,
                keywords: model.SearchProductName,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize,
                showHidden: true
                );

            gridModel.Data  = products.Select(x => x.ToModel());
            gridModel.Total = products.TotalCount;

            return(Json(gridModel));
        }
Ejemplo n.º 2
0
        public virtual ActionResult ProductAddPopup(string btnId, string formId, DestinationModel.AddDestinationProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDestinations))
            {
                return(AccessDeniedView());
            }

            if (model.SelectedProductIds != null)
            {
                foreach (int id in model.SelectedProductIds)
                {
                    var product = _productService.GetProductById(id);
                    if (product != null)
                    {
                        var existingProductdestinations = _destinationService.GetProductDestinationsByDestinationId(model.DestinationId, showHidden: true);
                        if (existingProductdestinations.FindProductDestination(id, model.DestinationId) == null)
                        {
                            _destinationService.InsertProductDestination(
                                new ProductDestination
                            {
                                DestinationId     = model.DestinationId,
                                ProductId         = id,
                                IsFeaturedProduct = false,
                                DisplayOrder      = 1
                            });
                        }
                    }
                }
            }

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View(model));
        }
Ejemplo n.º 3
0
        public virtual ActionResult ProductAddPopup(int destinationId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDestinations))
            {
                return(AccessDeniedView());
            }

            var model = new DestinationModel.AddDestinationProductModel();

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