Ejemplo n.º 1
0
        public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = null)] HttpRequest req, ILogger log)
        {
            log.LogInformation("Deleting the product ...");

            string productId = req.Query["productId"];

            if (string.IsNullOrEmpty(productId))
            {
                return(new BadRequestObjectResult("Product Id is required"));
            }

            var productsRepository = new ProductsRepository();

            var result = await productsRepository.DeleteProductAsync(productId);

            if (result.IsSuccess)
            {
                return(new NoContentResult());
            }

            return(new BadRequestObjectResult(result.Errors[0]));
        }