public ActionResult Add(CategoryModel Model) { if (!ModelState.IsValid) { ViewBag.Parent = new SelectList(_categoryBL.GetListParent(), "id", "name"); return(View(Model)); } List <string> lstMsg = new List <string>(); int returnCode = _categoryBL.Insert(Model, out lstMsg); if (!((int)Common.ReturnCode.Succeed == returnCode)) { ViewBag.Parent = new SelectList(_categoryBL.GetListParent(), "id", "name"); if (lstMsg != null) { for (int i = 0; i < lstMsg.Count(); i++) { ModelState.AddModelError(string.Empty, lstMsg[i]); } } return(View(Model)); } TempData["Success"] = "Inserted Successfully!"; return(RedirectToAction("Index")); }
protected void Button2_Click(object sender, EventArgs e) { string NewCat = CatTxt.Text; CategoryBL.Insert(NewCat); FillGridView(); CatTxt.Visible = false; AddBtn.Visible = false; }
/// <summary> /// If the model is valid, the user can create a new category. /// </summary> /// <param name="category"></param> /// <returns></returns> public ActionResult CreateCategory(CATEGORIES category) { try { if (ModelState.IsValid) { objBS.Insert(category); return(RedirectToAction("Index", new { afterCreateCageory = category.CategoryName + " kategória sikeresen létrehozva!" })); } return(View("Create")); } catch { TempData["Msg"] = "A kategória létrehozása sikertelen"; return(RedirectToAction("Create")); } }