Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public ActionResult AddAttribute(AttributeModel model, int cateId = -1)
        {
            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId);

            if (categoryInfo == null)
            {
                return(PromptView("分类不存在"));
            }

            if (AdminCategories.GetAttrIdByCateIdAndName(cateId, 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, attributeGroupInfo);
                AddAdminOperateLog("添加分类属性", "添加分类属性,属性为:" + model.AttributName);
                return(PromptView("分类属性添加成功"));
            }
            ViewData["cateId"]             = categoryInfo.CateId;
            ViewData["categoryName"]       = categoryInfo.Name;
            ViewData["attributeGroupList"] = GetAttributeGroupSelectList(cateId);
            ViewData["referer"]            = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }