// GET: api/DataTablesPatient/c public HttpResponseMessage Get(char id, [FromUri] dataTableRequest thisRequest) { JObject reply = new JObject(); PatientLogic pl = new PatientLogic(); try { JArray records = null; int recordCount = 0; char[] requestOrder = thisRequest.order[0].dir.ToCharArray(); char order = requestOrder[0]; switch (id) { case 'c': //current records = JArray.Parse(JsonConvert.SerializeObject(pl.GetPatients(out recordCount, 'C', thisRequest.order[0].dir, thisRequest.columns[thisRequest.order[0].column].data))); break; case 'h': //historical records = JArray.Parse(JsonConvert.SerializeObject(pl.GetPatients(out recordCount,'H', thisRequest.order[0].dir, thisRequest.columns[thisRequest.order[0].column].data))); break; case 'a': //all records = JArray.Parse(JsonConvert.SerializeObject(pl.GetPatients(out recordCount, 'A', thisRequest.order[0].dir, thisRequest.columns[thisRequest.order[0].column].data))); break; default: break; } //The actual JSON response BuildDataTableJSONReply(records, thisRequest.draw, recordCount); } catch (Exception ex) { BuildHttpErrorResponse(ex); } return Response; }
// GET: api/DataTablesPatient //public IEnumerable<string> Get() public HttpResponseMessage Get([FromUri] dataTableRequest thisRequest) { NameValueCollection nvc = HttpUtility.ParseQueryString(Request.RequestUri.Query); JObject reply = new JObject(); PatientLogic pl = new PatientLogic(); try { int recordCount = 0; JArray records = JArray.Parse(JsonConvert.SerializeObject(pl.GetPatients(out recordCount), Formatting.None)); //draw parsed to int as per security recommendation in docs. BuildDataTableJSONReply(records, int.Parse(nvc["draw"]), recordCount); } catch (Exception ex) { BuildHttpErrorResponse(ex); } return Response; }