Exemplo n.º 1
0
        public async Task <ActionResult> AddProduct([FromBody] PostProductRequest productToAdd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else
            {
                GetProductDetailsResponse response = await _productCommands.AddProduct(productToAdd);

                return(CreatedAtRoute("products#getbyid", new { id = response.Id }, response));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Product> > PostProduct(Product product)
        {
            var result = await _command.AddProduct(product);

            return(CreatedAtAction("GetProduct", new { id = result.ProductId }, result));
        }