Example #1
0
        public async Task <IActionResult> Update(int id, [FromBody] ProductUpdateViewModel value)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var success = await _domainService.Update(id, value.Name, value.Description, value.Price);

                if (success)
                {
                    return(Ok("Product updated."));
                }
                else
                {
                    return(NotFound("Product not found."));
                }
            }
            catch
            {
                return(BadRequest("Unable to update the product."));
            }
        }
Example #2
0
        public async Task <GetProductOutput> Update(UpdateProductInput input)
        {
            var product = await _productDomainService.Update(input);

            return(product.MapTo <GetProductOutput>());
        }