Exemple #1
0
 public static void show(Long id) {
   System.out.printf("=== id: %d\n", id);
   List<AuctionItem> items = AuctionItem.findAll();
   for (AuctionItem item : items) {
     System.out.printf("--- id: %d\n", item.id);
   }
   AuctionItem item = AuctionItem.findById(id);
   item.viewCount++;
   item.save();
   render(item);
 }
Exemple #2
0
  public static void doCreateItem(@Valid AuctionItem item) throws IOException {

    if (validation.hasErrors()) {
      System.out.println(validation.errorsMap());
      render("@createAuctionItem", item);
    }

    // set the user based on the logged in user
    item.createdBy = Authenticate.getLoggedInUser();

    item.save();
    show(item.id);
  }
Exemple #3
0
  public static void search(String search, Integer page) {
    validation.required(search).message("You must enter something to search for");
    if (validation.hasErrors()) {
      render();
    }

    page = page == null ? 1 : page;

    SearchResults results = AuctionItem.search(search, page);
    render(results, page, search);
  }
Exemple #4
0
  public static void newBids(Long id) {
    // count new bids
    long newBids =
        Bid.count(
            "from AuctionItem a join a.bids as b " + "where a.id = ? AND b.date > ?",
            id,
            request.date);

    // wait if needed
    if (newBids == 0) {
      await("1s");
    }

    // return the JSON output of the new bids
    AuctionItem item = AuctionItem.findById(id);

    JsonObject json = new JsonObject();
    json.addProperty("next", item.getNextBidPrice());
    json.addProperty("top", item.getCurrentTopBid());
    renderJSON(json.toString());
  }
Exemple #5
0
 public static void showImage(Long id) {
   AuctionItem item = AuctionItem.findById(id);
   response.setContentTypeIfNotSet(item.photo.type());
   renderBinary(item.photo.get());
 }
Exemple #6
0
 public static void index() {
   List<AuctionItem> mostPopular = AuctionItem.getMostPopular(5);
   List<AuctionItem> endingSoon = AuctionItem.getEndingSoon(5);
   render(mostPopular, endingSoon);
 }
Exemple #7
0
 public static void showPDF(Long id) {
   AuctionItem item = AuctionItem.findById(id);
   item.viewCount++;
   item.save();
   renderPDF(item);
 }
Exemple #8
0
 public static void recentlyAdded() {
   List<AuctionItem> items = AuctionItem.recentlyAdded(50);
   render(items);
 }
Exemple #9
0
 public static void addBid(Long id, Float amount) {
   AuctionItem item = AuctionItem.findById(id);
   item.addBid(amount);
   item.save();
 }