public ActionResult CategoryUpdate(CategoryDTO category) { CategoryBL bl = new CategoryBL(); List <CategoryDTO> list = new List <CategoryDTO>(); bl.SearchListUp(category, out list); ViewBag.CaterogyList = list; if (ModelState.IsValid) { category.updated_by = 0; int result = bl.UpdateData(category); if (result == 1) { TempData["Error"] = "Update badly"; TempData["Success"] = ""; return(View(category)); } else { TempData["Error"] = ""; TempData["Success"] = "Update successfully"; return(RedirectToAction("CategorySearch")); } } else { return(View(category)); } }
public ActionResult UpdateCategory(CategoryDTO category) { CategoryBL categoryBL = new CategoryBL(); try { if (ModelState.IsValid) { category.created_by = 123; category.updated_by = 123; if (category.id != category.parent_id) { categoryBL.UpdateData(category); return(RedirectToAction("Category")); } else { TempData["Error"] = "id and pararent_id is duplicated!"; } } } catch (DataException dex) { ModelState.AddModelError("", "Unable to perform action. Please contact us."); return(RedirectToAction("SubmissionFailed", category)); } category = new CategoryDTO() { id = category.id }; return(View("Update", LoadCategoryAddForm(category))); }
public ActionResult CategoryUpdate(CategoryDTO category) { CategoryBL bl = new CategoryBL(); category.created_by = 0; category.updated_by = 0; bl.UpdateData(category); return(RedirectToAction("CategorySearch")); }
public ActionResult UpdateCategory(CategoryDTO category) { try { if (ModelState.IsValid) { category.created_by = 123; category.updated_by = 123; if (category.id == category.parent_id) { ModelState.AddModelError("parent_id", "Parent Category is duplicated with current category"); } else { CommonData.ReturnCode returnCode = categoryBL.UpdateData(category); if (returnCode == CommonData.ReturnCode.Success) { TempData["Success"] = "Update Successfully!"; } else { TempData["Error"] = "Update fail"; } Session["model.Category"] = null; return(RedirectToAction("Category")); } } } catch (DataException dex) { ModelState.AddModelError("", "Lỗi không xác định"); return(RedirectToAction("SubmissionFailed", category)); } SelectList listCategory = new SelectList(categoryBL.SelectDropdownData(), "id", "name"); ViewBag.ListCategory = listCategory; return(View("Update", category)); }