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)); }
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(); AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attributeInfo.AttrGroupId); ViewData["attributeGroupName"] = attributeGroupInfo.Name; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
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)); }
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)); }
public ActionResult EditAttributeGroup(int attrGroupId = -1) { AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attrGroupId); if (attributeGroupInfo == null) { return(PromptView("属性分组不存在")); } AttributeGroupModel model = new AttributeGroupModel(); model.AttributeGroupName = attributeGroupInfo.Name; model.DisplayOrder = attributeGroupInfo.DisplayOrder; //CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeGroupInfo.CateId); //ViewData["cateId"] = categoryInfo.CateId; //ViewData["categoryName"] = categoryInfo.Name; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
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)); }