Beispiel #1
0
        public ActionResult AddAttribute(AttributeModel model)
        {
            if (AdminCategories.GetAttrIdByName(model.AttributName) > 0)
            {
                ModelState.AddModelError("AttributName", "名称已经存在");
            }

            //AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(model.AttrGroupId);
            //if (attributeGroupInfo == null || attributeGroupInfo.CateId != cateId)
            //    ModelState.AddModelError("AttrGroupId", "属性组不存在");

            if (ModelState.IsValid)
            {
                AttributeInfo attributeInfo = new AttributeInfo();
                attributeInfo.Name = model.AttributName;
                //attributeInfo.CateId = cateId;
                attributeInfo.AttrGroupId = model.AttrGroupId;
                attributeInfo.ShowType    = model.ShowType;
                //attributeInfo.IsFilter = model.IsFilter;
                attributeInfo.DisplayOrder = model.DisplayOrder;

                AdminCategories.CreateAttribute(attributeInfo, null);
                AddMallAdminLog("添加属性", "添加属性,属性为:" + model.AttributName);
                return(PromptView("属性添加成功"));
            }
            //ViewData["cateId"] = categoryInfo.CateId;
            //ViewData["categoryName"] = categoryInfo.Name;
            //ViewData["attributeGroupList"] = GetAttributeGroupSelectList(cateId);
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return(View(model));
        }
Beispiel #2
0
        public ActionResult EditAttribute(AttributeModel model, int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

            if (attributeInfo == null)
            {
                return(PromptView("属性不存在"));
            }

            int attrId2 = AdminCategories.GetAttrIdByName(model.AttributName);

            if (attrId2 > 0 && attrId2 != attrId)
            {
                ModelState.AddModelError("AttributName", "名称已经存在");
            }

            //AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(model.AttrGroupId);
            //if (attributeGroupInfo == null || attributeGroupInfo.CateId != attributeInfo.CateId)
            //    ModelState.AddModelError("AttrGroupId", "属性组不存在");

            if (ModelState.IsValid)
            {
                attributeInfo.Name        = model.AttributName;
                attributeInfo.AttrGroupId = model.AttrGroupId;
                //attributeInfo.IsFilter = model.IsFilter;
                attributeInfo.ShowType     = model.ShowType;
                attributeInfo.DisplayOrder = model.DisplayOrder;

                AdminCategories.UpdateAttribute(attributeInfo);
                AddMallAdminLog("编辑属性", "编辑属性,属性ID为:" + attrId);
                return(PromptView("属性修改成功"));
            }

            //CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeInfo.CateId);
            //ViewData["cateId"] = categoryInfo.CateId;
            //ViewData["categoryName"] = categoryInfo.Name;
            //ViewData["attributeGroupList"] = GetAttributeGroupSelectList(categoryInfo.CateId);
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return(View(model));
        }