DatStorm

Untitled

Mar 8th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. @POST
  2.     @Path("/buyItemsInCart")
  3.     @SuppressWarnings("unchecked")
  4.     public String buyItemsInCart() {
  5.  
  6.         HashMap<String, Integer> cart = (HashMap<String, Integer>) session.getAttribute("yourMapCart");
  7.         String sellItems = "";
  8.         for (Map.Entry<String, Integer> entry : cart.entrySet()) {
  9.             String itemID = entry.getKey();
  10.             Integer amount = entry.getValue();
  11.             sellItems = cloudAdapter.sellItems(itemID, String.valueOf(getID()), amount);
  12.             if (sellItems != null) {
  13.                 if (sellItems.contains("ok")) {
  14.                     break;
  15.                 } else if (sellItems.contains("soldOut")) {
  16.                     return "We dont have more in stock of that item";
  17.                 } else if (sellItems.contains("error")) {
  18.                     return "We can't sell you other shops items! Please buy from us";
  19.                 }
  20.                 return "Weird error";
  21.             } else {
  22.                 return "It went wrong trying to purchase your items";
  23.             }
  24.         }
  25.         return "You succesfully bought the items";
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment