Sandeep kumar

Sandeep kumar

  • NA
  • 58
  • 4.4k

How to return datatable data in array jason form in web Ap

May 29 2021 6:01 AM
I NEED IN THIS FORM OF DATA.Please help me
 
data: [
["10/05/2021", 5, 6,6],
["11/05/2021", 8, 9,4],
["12/05/2021", 4, 6,2],
["13/05/2021", 6, 5,6],
["14/05/2021", 4, 3,3],
["15/05/2021", 7, 7,4],
["16/05/2021", 8, 6,1],
],
 
Controller Part Code
  1. //http://localhost:58231/api/ManageCovidInfo/GetCovidAbsentismGrapgh  
  2. //  
  3. // [Authorize]  
  4. [HttpPost]  
  5. public HttpResponseMessage GetCovidAbsentismGrapgh(JObject jsonParam)  
  6. {  
  7. try  
  8. {  
  9. // UserIdentity UI = new UserIdentity((ClaimsIdentity)User.Identity);  
  10. // var UserID = Convert.ToInt32(UI.UserID);  
  11. ManageCovidInfo _MCI = new ManageCovidInfo();  
  12. var CD_Dtls = _MCI.GetCovidAbsentismGrapgh(jsonParam);  
  13. response = Request.CreateResponse(HttpStatusCode.OK, CD_Dtls);  
  14. }  
  15. catch (Exception ex)  
  16. {  
  17. response = Request.CreateResponse(JsonConvert.DeserializeObject("{\"StatusCode\":\"500\",\"ErrorMessage\":\"" + ex.Message + "\"}"));  
  18. }  
  19. return response;  
  20. }  
Class Part Code
  1. public DataTable GetCovidAbsentismGrapgh(JObject jsonParam)  
  2. {  
  3. CovidInfoDetails CID = new CovidInfoDetails();  
  4. object[] ParameterValues = new object[1];  
  5. ParameterValues[0] = (string)jsonParam["Company"];  
  6. DataTable dt = new DataTable();  
  7. try  
  8. {  
  9. dt = DataAccess.GetDataTable(DBProcedure.GetCovidAbsentismGrapgh, ParameterValues);  
  10. }  
  11. catch (Exception ex)  
  12. {  
  13. }  
  14. return dt;  
  15. }  

Answers (6)