Debasis Mund
Debasis Mund

Reputation: 9

I want to return a table and the number of rows present in the table as a response

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) 
} 

Upvotes: -1

Views: 158

Answers (1)

Derviş Kayımbaşıoğlu
Derviş Kayımbaşıoğlu

Reputation: 30655

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");
} 

Upvotes: 0

Related Questions