public string GetById(int id) { ResultObject result = new ResultObject(); try { result.Data = service.GetById(id); if (result.Data != null) { result.Success = 1; } return(JsonConvert.SerializeObject(result, Formatting.Indented, jsonSetting)); } catch (Exception e) { result.Message = "EXCEPTION: " + e.Message + "Stack: " + e.StackTrace; result.Data = null; return(JsonConvert.SerializeObject(result)); } }