//edit public ActionResult ProductAttributeValidationRulesPopup(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); var pva = _productAttributeService.GetProductVariantAttributeById(id); if (pva == null) //No attribute value found with the specified id return RedirectToAction("List", "Product"); var product = _productService.GetProductById(pva.ProductId); if (product == null) throw new ArgumentException("No product found with the specified id"); //a vendor should have access only to his products if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id) return RedirectToAction("List", "Product"); var model = new ProductModel.ProductVariantAttributeModel() { //prepare only used properties Id = pva.Id, ValidationRulesAllowed = pva.ValidationRulesAllowed(), AttributeControlTypeId = pva.AttributeControlTypeId, ValidationMinLength = pva.ValidationMinLength, ValidationMaxLength = pva.ValidationMaxLength, ValidationFileAllowedExtensions = pva.ValidationFileAllowedExtensions, ValidationFileMaximumSize = pva.ValidationFileMaximumSize, DefaultValue = pva.DefaultValue, }; return View(model); }
public ActionResult ProductVariantAttributeList(DataSourceRequest command, int productId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); var product = _productService.GetProductById(productId); if (product == null) throw new ArgumentException("No product found with the specified id"); //a vendor should have access only to his products if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id) return Content("This is not your product"); var productVariantAttributes = _productAttributeService.GetProductVariantAttributesByProductId(productId); var productVariantAttributesModel = productVariantAttributes .Select(x => { var pvaModel = new ProductModel.ProductVariantAttributeModel() { Id = x.Id, ProductId = x.ProductId, ProductAttribute = _productAttributeService.GetProductAttributeById(x.ProductAttributeId).Name, ProductAttributeId = x.ProductAttributeId, TextPrompt = x.TextPrompt, IsRequired = x.IsRequired, AttributeControlType = x.AttributeControlType.GetLocalizedEnum(_localizationService, _workContext), AttributeControlTypeId = x.AttributeControlTypeId, DisplayOrder = x.DisplayOrder }; if (x.ShouldHaveValues()) { pvaModel.ViewEditValuesUrl = Url.Action("EditAttributeValues", "Product", new { productVariantAttributeId = x.Id }); pvaModel.ViewEditValuesText = string.Format(_localizationService.GetResource("Admin.Catalog.Products.ProductVariantAttributes.Attributes.Values.ViewLink"), x.ProductVariantAttributeValues != null ? x.ProductVariantAttributeValues.Count : 0); } pvaModel.ValidationRulesAllowed = x.ValidationRulesAllowed(); return pvaModel; }) .ToList(); var gridModel = new DataSourceResult { Data = productVariantAttributesModel, Total = productVariantAttributesModel.Count }; return Json(gridModel); }
public List<ProductModel.ProductVariantAttributeModel> ProductVariantAttributeListobj(DataSourceRequest command, int productId) { var product = _productService.GetProductById(productId); if (product == null) throw new ArgumentException("No product found with the specified id"); var productVariantAttributes = _productAttributeService.GetProductVariantAttributesByProductId(productId); var productVariantAttributesModel = productVariantAttributes .Select(x => { var pvaModel = new ProductModel.ProductVariantAttributeModel() { Id = x.Id, ProductId = x.ProductId, ProductAttribute = _productAttributeService.GetProductAttributeById(x.ProductAttributeId).Name, ProductAttributeId = x.ProductAttributeId, TextPrompt = x.TextPrompt, IsRequired = x.IsRequired, AttributeControlType = x.AttributeControlType.GetLocalizedEnum(_localizationService, _workContext), AttributeControlTypeId = x.AttributeControlTypeId, DisplayOrder = x.DisplayOrder }; if (x.ShouldHaveValues()) { pvaModel.ViewEditValuesUrl = Url.Action("EditAttributeValues", "Product", new { productVariantAttributeId = x.Id }); pvaModel.ViewEditValuesText = string.Format(_localizationService.GetResource("Admin.Catalog.Products.ProductVariantAttributes.Attributes.Values.ViewLink"), x.ProductVariantAttributeValues != null ? x.ProductVariantAttributeValues.Count : 0); } pvaModel.ValidationRulesAllowed = x.ValidationRulesAllowed(); return pvaModel; }) .ToList(); return productVariantAttributesModel; }