Beispiel #1
0
        public async Task SetProductPrice(ProductPriceUpdate priceUpdate)
        {
            Product product = await _repo.GetById(priceUpdate.ProductId);

            product.Price       = priceUpdate.ProductPrice;
            product.UpdatedDate = DateTime.Now;
            await _repo.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task <IActionResult> Post([FromBody] ProductPriceUpdate priceUpdate)
        {
            try
            {
                await _service.SetProductPrice(priceUpdate);

                return(Ok());
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Error setting new Product price. Exception: {e}");
                return(ServerError(new MessageResponse()
                {
                    Message = "Unexpected error has occurred"
                }));
            }
        }