/// <summary>Creates the regulationAuthority.</summary> /// <param name="regulationAuthority">The regulationAuthority.</param> /// <returns>A JSON encoded success indicator</returns> public JsonResult Create(RegulationAuthority regulationAuthority) { try { var farmContext = new PicolEntities(); farmContext.RegulationAuthorities.Add(regulationAuthority); farmContext.SaveChanges(); return(new JsonNetResult { Data = new { Error = false, RegulationAuthority = regulationAuthority }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception e) { // Signal the error to be logged by elmah ErrorSignal.FromCurrentContext().Raise(e); return(new JsonNetResult { Data = new { Error = true, ErrorMessage = "Failed save regulationAuthority." }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
/// <summary>Updates the regulationAuthority.</summary> /// <param name="regulationAuthority">The regulationAuthority.</param> /// <returns>A JSON encoded success indicator</returns> public JsonResult Update(RegulationAuthority regulationAuthority) { try { var farmContext = new PicolEntities(); farmContext.RegulationAuthorities.Attach(regulationAuthority); farmContext.Entry(regulationAuthority).State = System.Data.Entity.EntityState.Modified; farmContext.SaveChanges(); return(new JsonNetResult { Data = new { Error = false }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception e) { // Signal the error to be logged by elmah ErrorSignal.FromCurrentContext().Raise(e); return(new JsonNetResult { Data = new { Error = true, ErrorMessage = "Failed to update regulationAuthority." }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }