What is Best way to return Data in webapi : <p>I have a question that what is the best way to return data in webapi.
for eg we can have 2 scenarios.</p>

<blockquote>
  <p>1) GetProductsById in which we recive an id and return data for that Id.</p>
  
  <p>2) GetProducts in which we return list of data</p>
</blockquote>

<p>so for GetProductsById we can do : </p>

<pre><code> public IHttpActionResult GetProduct(int id)
    {
        var product = getProducts().FirstOrDefault((p) =&gt; p.Id == id);
        if (product == null)
        {
            return NotFound();
        }
        return Ok(product);
    }
</code></pre>

<p>and for getting list:</p>

<pre><code> public IHttpActionResult GetProduct(int id)
    {
        var products = getproducts();
        if (products == null)
        {
            throw new NotFoundException()
        }
        return Ok(product);
    }
</code></pre>

<p>I want to know the best method to handle not found scenario in both cases.</p>
