public IHttpActionResult Post(Mortgage mortgage) { if (mortgage.LoanAmount == 0 || mortgage.TermsInMonths == 0) { var resp = new HttpResponseMessage(System.Net.HttpStatusCode.NotFound) { Content = new StringContent("Mortgage loan amount or duration cannot be 0"), ReasonPhrase = "Mortgage loan amount or duration cannot be 0" }; throw new HttpResponseException(resp); } var mortgageResponseObject = mortgageService.CalculateMortgage(mortgage); if (mortgageResponseObject == null) { return(NotFound()); } return(Ok(mortgageResponseObject)); }