Closed stanislavtrifonov88 closed 4 years ago
-Added separate transaction for for creating a contract and returning a car -Manually tested by including a "throw new error ..." after saving the first entity but before saving the second. Neither got updated.
When creating contact you do the following:
save the contract Save the car with flag is borrowed if 1 succeeds and 2 fails (due to temporary lost connection to the database) you will end up with a contract on the car and the car will be also available to be rented. Option 1: change your db schema so that the car does not have it's own property isBorrowed, but borrowed is inherited form whether the car has active contract or not. Option 2: Do those actions in transaction. "All or nothings" strategy
You have the same issue on return a car