-1

I have to send the noOfRecords variable in the response.

public HttpResponseMessage GetWareHouses(int pageNumber, int noofRows) 
{ 
var result = myModelObject.SelectTableData(pageNumber, noofRows); 
int numberOfRec = result.Count; /*I need to send this data in response.*/ 
if(numberOfRec>0) 
return  Request.CreateResponse(HttpStatusCode.OK, result) 
} 
  • Did you check this post? https://stackoverflow.com/questions/11733205/how-web-api-returns-multiple-types – abhiJ Oct 14 '20 at 12:50

1 Answers1

0

In your function, there are at least two problems.

  1. All paths needs to return a value. In your function, It is not.
  2. If you are using Controllers to return value, I advice you to use IActionResult

thus

public IActionResult GetWareHouses(int pageNumber, int noofRows) 
{ 
    var result = myModelObject.SelectTableData(pageNumber, noofRows); 
    int numberOfRec = result.Count; 

    if(numberOfRec>0) 
        return Ok(result) ;

    return BadRequest("problem");
} 
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72