Skip to content
Snippets Groups Projects
Commit 00b1f18a authored by michael.ramusi's avatar michael.ramusi
Browse files
parents c887756a a543c7b6
No related branches found
No related tags found
No related merge requests found
......@@ -84,8 +84,13 @@ public class AccountService{
//------------------------------------------
if (obj instanceof EventCreditAnAccount){
EventCreditAnAccount e = (EventCreditAnAccount) obj;
accountsDB.creditAnAccount(e.idAccount(), e.amount());
send(new EventAccountCredited(e.id(), "The account is credited"));
if(accountsDB.accountPresent(e.idAccount())){
accountsDB.creditAnAccount(e.idAccount(), e.amount());
send(new EventAccountCredited(e.id(), "The account is credited"));
}
else{
send(new EventAccountDoesntExist(e.id(), "The account doesn't exist"));
}
System.out.println(e.toString());
}
//------------------------------------------
......
......@@ -89,8 +89,14 @@ public class StockService {
// ------------------------------------------
if (obj instanceof EventAddProductQuantity) {
EventAddProductQuantity e = (EventAddProductQuantity) obj;
stockDB.addQuantity(e.idProduct(), e.quantity());
send(new EventProductQuantityAdded(e.id(), "Quantity added to the stock"));
if(productsDB.getById(e.idProduct()).isPresent()){
stockDB.addQuantity(e.idProduct(), e.quantity());
send(new EventProductQuantityAdded(e.id(), "Quantity added to the stock"));
}
else{
send(new EventProductDoesntExist(e.id(), "Product doesn't exist"));
}
System.out.println(e.toString());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment