Exemplo n.º 1
0
        public ActionResult EditAttributeGroup(AttributeGroupModel model, int attrGroupId = -1)
        {
            AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attrGroupId);

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

            int attrGroupId2 = AdminCategories.GetAttributeGroupIdByCateIdAndName(attributeGroupInfo.CateId, model.AttributeGroupName);

            if (attrGroupId2 > 0 && attrGroupId2 != attrGroupId)
            {
                ModelState.AddModelError("AttributeGroupName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                attributeGroupInfo.Name         = model.AttributeGroupName;
                attributeGroupInfo.DisplayOrder = model.DisplayOrder;

                AdminCategories.UpdateAttributeGroup(attributeGroupInfo);
                AddAdminOperateLog("修改属性分组", "修改属性分组,属性分组ID为:" + attrGroupId);
                return(PromptView("属性分组修改成功"));
            }

            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeGroupInfo.CateId);

            ViewData["cateId"]       = categoryInfo.CateId;
            ViewData["categoryName"] = categoryInfo.Name;
            ViewData["referer"]      = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AddAttributeGroup(AttributeGroupModel model, int cateId = -1)
        {
            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId);

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

            if (AdminCategories.GetAttributeGroupIdByCateIdAndName(cateId, model.AttributeGroupName) > 0)
            {
                ModelState.AddModelError("AttributeGroupName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                AttributeGroupInfo attributeGroupInfo = new AttributeGroupInfo()
                {
                    Name         = model.AttributeGroupName,
                    CateId       = categoryInfo.CateId,
                    DisplayOrder = model.DisplayOrder
                };

                AdminCategories.CreateAttributeGroup(attributeGroupInfo);
                AddAdminOperateLog("添加属性分组", "添加属性分组,属性分组为:" + model.AttributeGroupName);
                return(PromptView("属性分组添加成功"));
            }
            ViewData["cateId"]       = categoryInfo.CateId;
            ViewData["categoryName"] = categoryInfo.Name;
            ViewData["referer"]      = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }