public ActionResult CreateProductCategory(ProductCategory productCategory) { if (ModelState.IsValid) { var service = new ProductCategoryService(); int id = service.Insert(productCategory); if (id > 0) { SetAlert("Thêm danh mục sản phẩm thành công!", "success"); return(RedirectToAction("Index", "ProductCategoryAdmin")); } else { ModelState.AddModelError("", "Thêm danh mục sản phẩm thất bại!"); } } return(View("Index")); }
public bool InsertProductCategory() { //var option = int.Parse(HttpContext.Current.Request.Form["parentSelect"]); var model = new ProductCategoryInfo(); model.Name = HttpContext.Current.Request.Form["CategoryName"]; model.Desc = HttpContext.Current.Request.Form["desc"]; model.MediumPicture = HttpContext.Current.Request.Form["mediumpicture"]; model.ParentId = int.Parse(HttpContext.Current.Request.Form["parentSelect"]); var display = 0; if (int.TryParse(HttpContext.Current.Request.Form["DisplayOrder"], out display)) { model.DisplayOrder = display; } else { model.DisplayOrder = display; } IProductCategoryService productCategoryService = new ProductCategoryService(); return(productCategoryService.Insert(model, 1) > 0); }