Exemple #1
0
        public void ProductSpecificationAttributeOptionController_Add_NotHappensIfNotValidAttributeIdIsSent()
        {
            var controller = GetProductSpecificationAttributeOptionController();
            var attribute  = new ProductSpecificationAttribute();
            var option     = new ProductSpecificationAttributeOption()
            {
                ProductSpecificationAttribute = attribute
            };

            var add = controller.Add(attribute.Id);

            A.CallTo(() => _productOptionManager.AddSpecificationAttributeOption(option)).MustNotHaveHappened();
        }
        public JsonResult AddSpecification(string value, int option = 0, int productId = 0)
        {
            if (!String.IsNullOrWhiteSpace(value) && option != 0 && productId != 0)
            {
                ProductSpecificationAttribute attribute = _productOptionManager.GetSpecificationAttribute(option);
                if (_productOptionManager.ListSpecificationAttributeOptions(option).All(x => x.Name != value))
                {
                    _productOptionManager.AddSpecificationAttributeOption(new ProductSpecificationAttributeOption
                    {
                        Name = value,
                        ProductSpecificationAttribute = attribute
                    });
                }
                _productOptionManager.SetSpecificationValue(_productService.Get(productId), attribute, value);
                return(Json(true));
            }

            return(Json(false));
        }
 public ActionResult Add(ProductSpecificationAttributeOption option)
 {
     if (option.ProductSpecificationAttribute.Id != 0)
     {
         ProductSpecificationAttribute productSpecificationAttribute = _productOptionManager.GetSpecificationAttribute(option.ProductSpecificationAttribute.Id);
         if (productSpecificationAttribute != null)
         {
             if (ModelState.IsValid)
             {
                 _productOptionManager.AddSpecificationAttributeOption(option);
                 return(RedirectToAction("Index", new { attributeId = option.ProductSpecificationAttribute.Id }));
             }
             else
             {
                 return(PartialView(option));
             }
         }
     }
     return(RedirectToAction("Index", "ProductSpecificationAttribute"));
 }