public ActionResult Edit(WeightFormulaType model) { if (model.Action == "Delete") { WeightFormulaType entity = CarraraSQL.WeightFormulaTypes.Find(model.WeightFormulaTypeID); if (entity.MarkTypes.Any()) { return(Content("Whoops…The Weight Formula Type Is In Use And Was NOT Deleted!", "text/plain")); } try { CarraraSQL.WeightFormulaTypes.Remove(entity); CarraraSQL.SaveChanges(); HttpContext.Cache.Remove("WeightFormulaTypesSelectList"); return(Content("OK", "text/plain")); } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message = ex.InnerException.Message; } return(Content(string.Concat("Whoops…", message), "text/plain")); } } if (ModelState.IsValid) { CarraraSQL.Entry(model).State = EntityState.Modified; CarraraSQL.SaveChanges(); HttpContext.Cache.Remove("WeightFormulaTypesSelectList"); return(PartialView("Row", model)); } return(ReturnError()); }
public ActionResult Edit(int guid) { WeightFormulaType model = CarraraSQL.WeightFormulaTypes.Find(guid); RouteValueDictionary parameters = Request.QueryString.ToRouteValues(); if (model == null) { return(Content(string.Concat("Whoops…Unable to Locate Weight Formula Type with Id ", guid.ToString(), "!"), "text/plain")); } return(PartialView("Manage", model)); }
public ActionResult Add(WeightFormulaType model) { RouteValueDictionary parameters = Request.QueryString.ToRouteValues(); if (ModelState.IsValid) { CarraraSQL.WeightFormulaTypes.Add(model); CarraraSQL.SaveChanges(); HttpContext.Cache.Remove("WeightFormulaTypesSelectList"); return(PartialView("Row", model)); } return(ReturnError()); }