コード例 #1
0
        public virtual async Task <CustomerActionConditionModel.AddProductToConditionModel> PrepareAddProductToConditionModel(string customerActionId, string conditionId)
        {
            var model = new CustomerActionConditionModel.AddProductToConditionModel();

            model.CustomerActionConditionId = conditionId;
            model.CustomerActionId          = customerActionId;
            //categories
            model.AvailableCategories.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = " "
            });
            var categories = await _categoryService.GetAllCategories(showHidden : true);

            foreach (var c in categories)
            {
                model.AvailableCategories.Add(new SelectListItem {
                    Text = c.GetFormattedBreadCrumb(categories), Value = c.Id.ToString()
                });
            }

            //manufacturers
            model.AvailableManufacturers.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = " "
            });
            foreach (var m in await _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 = " "
            });
            foreach (var s in await _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 = " "
            });
            foreach (var v in await _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 = " "
            });

            return(model);
        }
コード例 #2
0
 public async Task<IActionResult> ProductAddPopup(CustomerActionConditionModel.AddProductToConditionModel model)
 {
     if (model.SelectedProductIds != null)
     {
         await _customerActionViewModelService.InsertProductToConditionModel(model);
     }
     ViewBag.RefreshPage = true;
     return View(model);
 }
コード例 #3
0
        public IActionResult ProductAddPopupList(DataSourceRequest command, CustomerActionConditionModel.AddProductToConditionModel model)
        {
            var products  = _customerActionViewModelService.PrepareProductModel(model, command.Page, command.PageSize);
            var gridModel = new DataSourceResult();

            gridModel.Data  = products.products.ToList();
            gridModel.Total = products.totalCount;

            return(Json(gridModel));
        }
 public virtual void InsertProductToConditionModel(CustomerActionConditionModel.AddProductToConditionModel model)
 {
     foreach (string id in model.SelectedProductIds)
     {
         var customerAction = _customerActionService.GetCustomerActionById(model.CustomerActionId);
         if (customerAction != null)
         {
             var condition = customerAction.Conditions.FirstOrDefault(x => x.Id == model.CustomerActionConditionId);
             if (condition != null)
             {
                 if (condition.Products.Where(x => x == id).Count() == 0)
                 {
                     condition.Products.Add(id);
                     _customerActionService.UpdateCustomerAction(customerAction);
                 }
             }
         }
     }
 }
コード例 #5
0
        public virtual async Task <CustomerActionConditionModel.AddProductToConditionModel> PrepareAddProductToConditionModel(string customerActionId, string conditionId)
        {
            var model = new CustomerActionConditionModel.AddProductToConditionModel();

            model.CustomerActionConditionId = conditionId;
            model.CustomerActionId          = customerActionId;

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = _translationService.GetResource("Admin.Common.All"), Value = " "
            });
            foreach (var s in await _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Shortcut, Value = s.Id.ToString()
                });
            }

            //vendors
            model.AvailableVendors.Add(new SelectListItem {
                Text = _translationService.GetResource("Admin.Common.All"), Value = " "
            });
            foreach (var v in await _vendorService.GetAllVendors(showHidden: true))
            {
                model.AvailableVendors.Add(new SelectListItem {
                    Text = v.Name, Value = v.Id.ToString()
                });
            }

            //product types
            model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList().ToList();
            model.AvailableProductTypes.Insert(0, new SelectListItem {
                Text = _translationService.GetResource("Admin.Common.All"), Value = " "
            });

            return(model);
        }
コード例 #6
0
        public virtual async Task <(IList <ProductModel> products, int totalCount)> PrepareProductModel(CustomerActionConditionModel.AddProductToConditionModel model, int pageIndex, int pageSize)
        {
            var productService = _serviceProvider.GetRequiredService <IProductService>();
            var products       = await productService.PrepareProductList(model.SearchCategoryId, model.SearchManufacturerId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);

            return(products.Select(x => x.ToModel(_dateTimeHelper)).ToList(), products.TotalCount);
        }
コード例 #7
0
        public virtual (IList <ProductModel> products, int totalCount) PrepareProductModel(CustomerActionConditionModel.AddProductToConditionModel model, int pageIndex, int pageSize)
        {
            var productService = Grand.Core.Infrastructure.EngineContext.Current.Resolve <IProductService>();
            var products       = productService.PrepareProductList(model.SearchCategoryId, model.SearchManufacturerId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);

            return(products.Select(x => x.ToModel()).ToList(), products.TotalCount);
        }
コード例 #8
0
        public virtual async Task <(IList <ProductModel> products, int totalCount)> PrepareProductModel(CustomerActionConditionModel.AddProductToConditionModel model, int pageIndex, int pageSize)
        {
            var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);

            return(products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount);
        }