Exemplo n.º 1
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"]            = ShopUtils.GetAdminRefererCookie();

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AddAttributeValue(int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

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

            AttributeValueModel model = new AttributeValueModel();

            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Exemplo n.º 3
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);
                AddAdminOperateLog("编辑分类属性", "编辑分类属性,分类属性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"]            = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult AddAttributeValue(AttributeValueModel model, int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

            if (attributeInfo == null)
            {
                ModelState.AddModelError("AttributName", "属性不存在");
            }

            if (AdminCategories.GetAttributeValueIdByAttrIdAndValue(attrId, model.AttrValue) > 0)
            {
                ModelState.AddModelError("AttributName", "值已经存在");
            }


            if (ModelState.IsValid)
            {
                AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attributeInfo.AttrGroupId);
                AttributeValueInfo attributeValueInfo = new AttributeValueInfo();

                attributeValueInfo.AttrId           = attributeInfo.AttrId;
                attributeValueInfo.AttrName         = attributeInfo.Name;
                attributeValueInfo.AttrDisplayOrder = attributeInfo.DisplayOrder;
                attributeValueInfo.AttrShowType     = attributeInfo.ShowType;

                attributeValueInfo.AttrGroupId           = attributeGroupInfo.AttrGroupId;
                attributeValueInfo.AttrGroupName         = attributeGroupInfo.Name;
                attributeValueInfo.AttrGroupDisplayOrder = attributeGroupInfo.DisplayOrder;

                attributeValueInfo.AttrValue             = model.AttrValue;
                attributeValueInfo.IsInput               = 0;
                attributeValueInfo.AttrValueDisplayOrder = model.DisplayOrder;

                AdminCategories.CreateAttributeValue(attributeValueInfo);
                AddAdminOperateLog("添加属性值", "添加属性值,属性值为:" + model.AttrValue);
                return(PromptView("属性值添加成功"));
            }
            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 属性值列表
        /// </summary>
        public ActionResult AttributeValueList(int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

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

            AttributeValueListModel model = new AttributeValueListModel()
            {
                AttributeValueList = AdminCategories.GetAttributeSelectValueListByAttrId(attrId),
                AttrId             = attributeInfo.AttrId,
                AttributeName      = attributeInfo.Name,
                CateId             = attributeInfo.CateId
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?attrId={1}", Url.Action("attributevaluelist"), attrId));
            return(View(model));
        }