public async Task <IActionResult> CreateAsync([FromBody] Product product)
        {
            if (product == null)
            {
                return(BadRequest(ModelState));
            }

            bool created = await productRepository.CreateAsync(product);

            if (!created)
            {
                return(BadRequest($"{product.Id} already exists"));
            }

            return(CreatedAtRoute("GetProductsById", new { id = product.Id }, product));
        }
Exemple #2
0
 public async Task <bool> CreateProductAsync(Product product)
 {
     return(await productRepository.CreateAsync(product));
 }