public IActionResult Post([FromBody] Product product) { if (product == null) { return(BadRequest(ErrorResponse.BadRequestError(1, "missing product", nameof(product)))); } product.Map(out Domain.Primitivies.Product domainProduct); try { string id = productCatalog.AddNewProduct(domainProduct); // respond with 201, including a link to the get action with id and the product return(CreatedAtRoute("GetProduct", new { id }, domainProduct.MapTo <Product>())); } catch (ProductConstraintViolatedException ex) { return(BadRequest(ErrorResponse.BadRequestError(2, $"invalid product body {ex.Message}", nameof(product)))); } // let controller/global exception filter kick in. }