예제 #1
0
        public ActionResult ProductAddPopupList(DataSourceRequest command, CustomerRoleProductModel.AddProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();

            var products = _productService.SearchProducts(
                categoryIds: new List<int> { model.SearchCategoryId },
                manufacturerId: model.SearchManufacturerId,
                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
                );
            var gridModel = new DataSourceResult();
            gridModel.Data = products.Select(x => x.ToModel());
            gridModel.Total = products.TotalCount;

            return Json(gridModel);
        }
예제 #2
0
        public ActionResult ProductUpdate(CustomerRoleProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
                return AccessDeniedView();

            var crp = _customerService.GetCustomerRoleProductById(model.Id);
            if (crp == null)
                throw new ArgumentException("No customer role product found with the specified id");

            crp.DisplayOrder = model.DisplayOrder;
            _customerService.UpdateCustomerRoleProduct(crp);

            return new NullJsonResult();
        }
예제 #3
0
        public ActionResult ProductAddPopup(string btnId, CustomerRoleProductModel.AddProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();

            if (model.SelectedProductIds != null)
            {
                foreach (int id in model.SelectedProductIds)
                {
                    var product = _productService.GetProductById(id);
                    if (product != null)
                    {
                        var customerRoleProduct = _customerService.GetCustomerRoleProduct(model.CustomerRoleId, id);
                        if(customerRoleProduct==null)
                        {
                            customerRoleProduct = new CustomerRoleProduct();
                            customerRoleProduct.CustomerRoleId = model.CustomerRoleId;
                            customerRoleProduct.ProductId = id;
                            customerRoleProduct.DisplayOrder = 0;
                            _customerService.InsertCustomerRoleProduct(customerRoleProduct);
                        }
                    }
                }
            }

            //a vendor should have access only to his products
            ViewBag.RefreshPage = true;
            ViewBag.btnId = btnId;
            return View(model);
        }