I have this example of ASP.NET Web Api controller:
public Mea Get(Int32 id)
{
try
{
return Meas.GetById(id) ?? new Mea(-1, 0D, 0D);
}
catch (Exception)
{
return new Mea(-1, 0D, 0D);
}
}
I want to be able to return a different response code if the GetById returns null or in the catch exception. All the examples that I see use HttpResponseMessage where you can add the response code. My question is how to change the response code when not using HttpResponseMessage, like in the above example?
HttpResponseMessage?