public ActionResult Create(Category category) { if (!ModelState.IsValid) { return(View(category)); } category.CreatedDate = DateTime.Now; category.CreatedBy = (Session[Constants.USER_SESSION] as UserLogin).UserID.ToString(); string addStatus = categoryDao.Add(category); if (addStatus == COMMON_CONSTANTS.ADD_FAIL) { return(RedirectToAction("Index", "Error")); } return(RedirectToAction("Index")); }
public ActionResult Create(string name) { Category category = new Category(); category.name = name; if (ModelState.IsValid) { dao.Add(category); return(RedirectToAction("Index")); } else { return(View(category)); } }
public static bool AddCategory(CategoryInfo category) { if (category == null) { return(false); } CategoryDao categoryDao = new CategoryDao(); category.CategoryId = categoryDao.GetMaxDisplaySequence <CategoryInfo>(); int categoryId; if (category.ParentCategoryId > 0) { CategoryInfo category2 = CatalogHelper.GetCategory(category.ParentCategoryId); string path = category2.Path; categoryId = category.CategoryId; category.Path = path + "|" + categoryId.ToString(); category.Depth = category2.Depth + 1; } else { categoryId = category.CategoryId; category.Path = categoryId.ToString(); category.Depth = 1; } Globals.EntityCoding(category, true); bool flag = categoryDao.Add(category, null) > 0; if (flag) { EventLogs.WriteOperationLog(Privilege.AddProductCategory, string.Format(CultureInfo.InvariantCulture, "创建了一个新的店铺分类:”{0}”", new object[1] { category.Name }), false); HiCache.Remove("DataCache-Categories"); } return(flag); }
/// <summary> /// 添加类别 /// </summary> /// <param name="name"></param> /// <returns></returns> public static bool Add(string name) { int res = CategoryDao.Add(name); return(res > 0); }