Ejemplo n.º 1
0
        public async Task <ActionResult <Product> > PostProduct([FromBody] Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!await productDAO.AddAsync(product))
            {
                return(StatusCode(productDAO.customError.StatusCode, productDAO.customError));
            }

            return(CreatedAtAction("GetProduct", new { id = product.Id }, product));
        }