Codit / practical-api-guidelines

Practical guidelines for building & designing APIs with .NET.
MIT License
16 stars 5 forks source link

Exclusive transaction #101

Closed MassimoC closed 5 years ago

MassimoC commented 5 years ago

Actually, all these operations on the database should be done inside a (exclusive) transaction, since a race-condition is introduced here.

It is possible that multiple sales requests for the same item are coming in at the same time. User A can retrieve the customization to check the inventory level, and that might be fine but by the time the ApplyCustomizationSaleAsync method is executed, the inventory level might already be changed to 0 by other incoming requests.

_Originally posted by @fgheysels