Skip to content

Instantly share code, notes, and snippets.

@cokeSchlumpf
Created January 9, 2020 21:26
Show Gist options
  • Save cokeSchlumpf/d101c48ebc373ab2fdc5ce0fc2e2d910 to your computer and use it in GitHub Desktop.
Save cokeSchlumpf/d101c48ebc373ab2fdc5ce0fc2e2d910 to your computer and use it in GitHub Desktop.
Sample
def orderEntry(order: Order): Try[OrderEntryProcessed] = {
order.items foreach { item =>
val stock = stockRepository.getProductById(item.product)
stock.amount = stock.amount - item.amount
stockRepository.updateStockItem(stock)
}
incredible_ai.checkForFraud(order)
payments.makePayment(order.paymentDetails)
coolBonusPointsSystem.giveBonusForOrder(order)
Success(OrderEntryProcessed(order.id, Instant.now()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment