Example #1
0
        public IActionResult UpdateProduct(int id, [FromBody] Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest(ErrorService.GetRequestContentMismatchErrorMessage()));
            }

            var existingProduct = _products.SingleOrDefault(p => p.Id == product.Id);

            if (existingProduct != null)
            {
                existingProduct = product;
                existingProduct.ModifiedDate = DateTime.UtcNow;
            }
            else
            {
                return(NotFound(ErrorService.GetEntityNotFoundErrorMessage(typeof(Product), product.Id)));
            }

            return(NoContent());
        }