public ActionResult AddAction(Category c) { CategoryDao cDao = new CategoryDao(); cDao.InsertCategory(c.Name, c.Position, c.Descriptions, c.Actives); return(RedirectToAction("List")); }
public ActionResult Create(Category category) { if (!String.IsNullOrWhiteSpace(category.Name)) { var categories = new CategoryDao().GetCategoryByName(category.Name); if (categories != null) { ModelState.AddModelError("", "Name Category is already registered"); } } if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.InsertCategory(category); if (id > 0) { SetNotification("Thêm mới danh mục thành công .", "success"); return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Thêm mới danh mục không thành công ."); } } SetViewBag(); return(View()); }
public ActionResult Create(Category cate) { var dao = new CategoryDao(); int id = dao.InsertCategory(cate); if (id > 0) { return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Them khong thanh cong"); } return(View("Index", "Home")); }
private static void DoCategoryjson(List <Category> listCategory, JObject jObjectData) { if (jObjectData.ContainsKey("category")) //处理dm { JArray jObjectCate = (JArray)jObjectData["category"]; foreach (JToken jToken in jObjectCate.Children()) { Category category = new Category(); category.category_id = int.Parse(jToken["category_id"].ToString()); category.name = jToken["name"].ToString(); Category oldCategory = CategoryDao.GetCategoryBycatId(category.category_id); if (oldCategory == null) { CategoryDao.InsertCategory(category); listCategory.Add(category); } } } }
/// <summary> /// InsertCategory - them thông tin category /// </summary> /// <param name="category"></param> /// <returns></returns> public bool InsertCategory(Category category) { return(categoryDao.InsertCategory(category)); }