Exemplo n.º 1
0
        public async Task <IActionResult> GetByProductAsync(Guid productId)
        {
            _logger.Information($"Executing GET - '/products/{productId}/options'");

            if (!ModelState.IsValid)
            {
                return(WebApi.Response.Error(new Error(ErrorCode.BadRequest, AppConstants.InvalidRequest)));
            }

            try
            {
                var result = await _productOptionService.GetByProductAsync(productId);

                return(result.IsSuccess()
                         ? WebApi.Response.Ok(result.Data)
                         : WebApi.Response.Error(result.Error));
            }
            catch (Exception ex)
            {
                _logger.Error("An error has occurred while getting product options. ProductId: {productId}, Details: {message}", productId, ex.Message);
            }

            return(WebApi.Response.Fatal());
        }