public object Post(Holiday added) { object json; string messageError = ""; try { Holiday posted = repository.Add(added, ref messageError); if (posted != null) { json = new { total = 1, data = posted, success = true }; } else { throw new System.InvalidOperationException(messageError); } } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); object error = new { message = ex.Message }; json = new { message = ex.Message, success = false }; }; return(json); }