public ActionResult Create(Category collection) { try { if (ModelState.IsValid) { var model = new CategoryModel(); int res = model.Create(collection.Name, collection.Alias, collection.ParentID, collection.Order, collection.Status); if (res > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm mới không thành công."); } } return(View(collection)); } catch { return(View()); } }
public ActionResult Create(Category collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here //insert here int res = cate.Create(collection); if (res > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm mới không thành công"); } } return(View(collection)); } catch { return(View()); } }
public ActionResult Create(Category collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here var model = new CategoryModel(); try { model.Create(collection); } catch { ModelState.AddModelError("", "Thêm mới không thành công"); } } return(RedirectToAction("Index", "Category")); } catch { return(View()); } }
public ActionResult Create(Category collection) { try { if (ModelState.IsValid) { var model = new CategoryModel(); var res = model.Create(collection.Name, collection.Alias, collection.Idx, collection.ParentId, (collection.Status ?? false)); if (res > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm mới dữ liệu không thành công!"); } } return(View(collection)); } catch (Exception ex) { return(View()); } }