public ActionResult Create(CategoryEditor catEditor) { try { if (!ModelState.IsValid) { var serviceInfo = new ServiceTypesLogics(); ViewBag.types = serviceInfo.GetServiceTypes().ToList().Select(x => new SelectListItem() { Value = x.Key.ToString(), Text = x.Value }); return(View(catEditor)); } CategoriesLogic catLogic = new CategoriesLogic(); catEditor.State = ObjectStatus.ObjectState.Create; //Set the object's state to Create List <CategoryEditor> catEditList = new List <CategoryEditor>(); catEditList.Add(catEditor); catLogic.EditCategories(catEditList); return(this.RedirectToAction("Index")); } catch { Console.WriteLine("Error creating new CategoryEditor"); return(View()); } }
public ActionResult Deactivate(CategoryEditor catEditor) { try { CategoriesLogic catLogic = new CategoriesLogic(); catEditor.State = ObjectStatus.ObjectState.Delete; //Set the object's state to Delete List <CategoryEditor> catDelList = new List <CategoryEditor>(); catDelList.Add(catEditor); catLogic.EditCategories(catDelList); //Sending the delete command to the CategoriesLogic object return(this.RedirectToAction("Index")); } catch { Console.WriteLine("Error deleting CategoryEditor " + catEditor.Id); return(View()); } }
public ActionResult Edit(CategoryEditor catEditor) { try { if (!ModelState.IsValid) { return(View(catEditor)); } CategoriesLogic catLogic = new CategoriesLogic(); var catEditList = this.EditHelper(catEditor); catLogic.EditCategories(catEditList); return(this.RedirectToAction("Index")); } catch { Console.WriteLine("Error updating CategoryEditor " + catEditor.Id); return(View()); } }