Esempio n. 1
0
        public ActionResult EditAttribute(AttributeModel model, int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);
            if (attributeInfo == null)
                return PromptView("属性不存在");

            int attrId2 = AdminCategories.GetAttrIdByCateIdAndName(attributeInfo.CateId, 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);
        }
Esempio 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);
                AddMallAdminLog("添加分类属性", "添加分类属性,属性为:" + model.AttributName);
                return PromptView("分类属性添加成功");
            }
            ViewData["cateId"] = categoryInfo.CateId;
            ViewData["categoryName"] = categoryInfo.Name;
            ViewData["attributeGroupList"] = GetAttributeGroupSelectList(cateId);
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return View(model);
        }
Esempio n. 3
0
        public ActionResult EditAttribute(int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);
            if (attributeInfo == null)
                return PromptView("属性不存在");

            AttributeModel model = new AttributeModel();
            model.AttributName = attributeInfo.Name;
            model.AttrGroupId = attributeInfo.AttrGroupId;
            model.ShowType = attributeInfo.ShowType;
            model.IsFilter = attributeInfo.IsFilter;
            model.DisplayOrder = attributeInfo.DisplayOrder;

            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);
        }
Esempio n. 4
0
        public ActionResult AddAttribute(int cateId = -1)
        {
            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId);
            if (categoryInfo == null)
                return PromptView("分类不存在");

            AttributeModel model = new AttributeModel();
            ViewData["cateId"] = categoryInfo.CateId;
            ViewData["categoryName"] = categoryInfo.Name;
            ViewData["attributeGroupList"] = GetAttributeGroupSelectList(cateId);
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return View(model);
        }