Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @POST
- @Path("/buyItemsInCart")
- @SuppressWarnings("unchecked")
- public String buyItemsInCart() {
- HashMap<String, Integer> cart = (HashMap<String, Integer>) session.getAttribute("yourMapCart");
- String sellItems = "";
- for (Map.Entry<String, Integer> entry : cart.entrySet()) {
- String itemID = entry.getKey();
- Integer amount = entry.getValue();
- sellItems = cloudAdapter.sellItems(itemID, String.valueOf(getID()), amount);
- if (sellItems != null) {
- if (sellItems.contains("ok")) {
- break;
- } else if (sellItems.contains("soldOut")) {
- return "We dont have more in stock of that item";
- } else if (sellItems.contains("error")) {
- return "We can't sell you other shops items! Please buy from us";
- }
- return "Weird error";
- } else {
- return "It went wrong trying to purchase your items";
- }
- }
- return "You succesfully bought the items";
- }
Advertisement
Add Comment
Please, Sign In to add comment