예제 #1
0
        public async Task <Result> UpdateProductAsync(ProductModel productModel)
        {
            Product productToUpdate = await _productRepository.GetByIdAsync(productModel.Id);

            if (productToUpdate == null)
            {
                return(new Result
                {
                    ResponseMessageType = ResponseMessageType.Error,
                    MessageDetails = "Product does not exist"
                });
            }

            productToUpdate = _productMapper.MapBack(productModel, productToUpdate);

            _productRepository.Update(productToUpdate);
            await _productRepository.SaveAsync();

            return(new Result
            {
                ResponseMessageType = ResponseMessageType.Success
            });
        }