public ActionResult Create(FormCollection collection) { bool DidItWork = false; string CrudAction = "Create"; try { MerchCat a = new MerchCat(); #region Pull from Form Collection a.MerchCatID = Convert.ToInt32(collection["MerchCatID"]); a.MerchCatDesc = (string)collection["MerchCatDesc"]; a.DeptID = Convert.ToInt32(collection["ddDept"]); a.CatID = Convert.ToInt32(collection["ddCat"]); a.MerchCatActive = Convert.ToInt32(collection["ddActive"]); #endregion StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer(); DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name); if (DidItWork == false) { return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name))); } else { return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { bool DidItWork = false; string CrudAction = "Delete"; try { MerchCatBusinessLayer bl = new MerchCatBusinessLayer(); MerchCat a = bl.MerchCats.Where(p => p.MerchCatID == id).Single(); StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer(); DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name); if (DidItWork == false) { return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name))); } else { return(RedirectToAction("Index")); } } catch { return(View()); } }