Skip to content

Instantly share code, notes, and snippets.

@jbogard
Last active April 8, 2019 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/7db553205f54a1d8ac0b64a7c91437f7 to your computer and use it in GitHub Desktop.
Save jbogard/7db553205f54a1d8ac0b64a7c91437f7 to your computer and use it in GitHub Desktop.
var orderRequest = await _orderRepository.GetItemAsync(id);
orderRequest.Approve();
await _orderRepository.UpdateItemAsync(orderRequest);
foreach (var lineItem in orderRequest.Items)
{
var stock = (await _stockRepository
.GetItemsAsync(s => s.ProductId == lineItem.ProductId))
.Single();
stock.QuantityAvailable -= lineItem.Quantity;
await _stockRepository.UpdateItemAsync(stock);
}
_client.Publish(new OrderApproved { OrderId = orderRequest.Id });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment