Exemple #1
0
        public async Task <UpdateProductOptionResponse> UpdateProductOption(Guid productId, Guid optionId, UpdateProductOptionRequest updateProductOptionRequest)
        {
            _logger.LogInformation($"Updating product option with productId: {productId} and optionId: {optionId}");

            var productOption = await _productRepository.GetProductOptionsByProductIdAndOptionsId(productId, optionId);

            if (productOption == null)
            {
                _logger.LogInformation($"Could not find product option with productId: {productId} and optionId: {optionId}");

                return(new UpdateProductOptionResponse
                {
                    IsSuccessful = false
                });
            }

            productOption.Name        = updateProductOptionRequest.Name;
            productOption.Description = updateProductOptionRequest.Description;

            var result = await _productRepository.UpdateProductOption(productOption);

            var updateProductOptionResponse = new UpdateProductOptionResponse
            {
                IsSuccessful = result
            };

            _logger.LogInformation($"Updated a product with IsSuccessful: {updateProductOptionResponse.IsSuccessful}");

            return(updateProductOptionResponse);
        }
Exemple #2
0
        public UpdateProductOptionResponse UpdateProductOption(UpdateProductOptionRequest request)
        {
            var response = new UpdateProductOptionResponse {
                Errors = new List <Error>()
            };

            try
            {
                Repository.UpdateProductOption(request.ProductOptionEntity);
                response.Message = "Product option updated successfully!";
            }
            catch (Exception ex)
            {
                response.Errors.Add(
                    new Error
                {
                    CustomisedMessage = "Unable to update product option",
                    StackTrace        = ex.StackTrace,
                    SystemMessage     = ex.Message,
                });

                Logger.Fatal(request);
                Logger.Fatal(response, ex);
            }
            return(response);
        }