Beispiel #1
0
        public ActionResult Edit(ProductAttrKeyVModel productAttrKeyVModel)
        {
            ProductAttrKey productAttrKey = new ProductAttrKey()
            {
                ID                = productAttrKeyVModel.ID,
                AttrName          = productAttrKeyVModel.AttrName,
                OrderNum          = productAttrKeyVModel.OrderNum,
                EnterType         = productAttrKeyVModel.EnterType,
                IsSku             = 1,
                ProductCategoryID = productAttrKeyVModel.ProductCategoryID,
                IsImg             = productAttrKeyVModel.IsImg
            };

            List <ProductAttrValue> attrValues = new List <ProductAttrValue>();

            if (productAttrKeyVModel.AttrValues != null)
            {
                foreach (var item in productAttrKeyVModel.AttrValues)
                {
                    ProductAttrValue productAttrValue = new ProductAttrValue()
                    {
                        AttrValue        = item,
                        ProductAttrKeyID = productAttrKey.ID
                    };
                    attrValues.Add(productAttrValue);
                }
            }

            var result = attrKeyBLL.Update(productAttrKey, attrValues);

            return(Json(new { state = result > 0, msg = result > 0 ? "修改成功!" : "修改失败!" }));
        }
Beispiel #2
0
        public ActionResult Add(ProductAttrKeyVModel productAttrKeyVModel)
        {
            ProductAttrKey productAttrKey = new ProductAttrKey()
            {
                AttrName          = productAttrKeyVModel.AttrName,
                OrderNum          = productAttrKeyVModel.OrderNum,
                EnterType         = productAttrKeyVModel.EnterType,
                IsSku             = 1,
                ProductCategoryID = productAttrKeyVModel.ProductCategoryID,
                IsImg             = productAttrKeyVModel.IsImg
            };

            attrKeyBLL.Add(productAttrKey);

            if (productAttrKeyVModel.AttrValues != null)
            {
                foreach (var item in productAttrKeyVModel.AttrValues)
                {
                    ProductAttrValue productAttrValue = new ProductAttrValue()
                    {
                        AttrValue        = item,
                        ProductAttrKeyID = productAttrKey.ID
                    };
                    attrValueBLL.Add(productAttrValue);
                }
            }

            return(Json(new { state = true, msg = "添加成功!" }));
        }