コード例 #1
0
 private void raiseDirectExchangeRejectedNotification(
     String notificationMessage, User userToNotify) {
   notificationsDao.saveNotification(
       new Notification.NotificationBuilder()
           .setMessage(notificationMessage)
           .setNotificationType(NotificationType.DIREXT_EXHANGE_REJECTED)
           .setDateCreated(LocalDateTime.now())
           .setUserNotified(userToNotify)
           .build());
 }
コード例 #2
0
  private void addNewExchangeRequestNotification(
      User postedBy, String exchangeInitiator, DirectBookExchange exchangeToRecord) {
    DirectExchangeInvitationNotification newExchangeRequestNotification =
        new DirectExchangeInvitationNotification.DirectExchangeNotificationBuilder()
            .setNotificationType(NotificationType.DIRECT_EXCHANGE_INVITATION)
            .setMessage(newExchangeRequestMessage + " " + exchangeInitiator)
            .setUserNotified(postedBy)
            .setDateCreated(LocalDateTime.now())
            .setDirectBookExchange(exchangeToRecord)
            .build();

    notificationsDao.saveNotification(newExchangeRequestNotification);
  }
コード例 #3
0
  public void acceptDirectExchange(String userEmail, int bookRequestedId, int exchangeId)
      throws BookExchangeInternalException {
    DirectBookExchange directBookExchange =
        bookExchangeDao
            .getDirectBookExchange(exchangeId)
            .orElseThrow(() -> new BookExchangeInternalException("No exchanges found"));
    Book bookRequestedInExchange =
        bookDao
            .getBookForId(bookRequestedId)
            .orElseThrow(() -> new BookExchangeInternalException("No book found"));

    updateBooksToInactive(bookRequestedInExchange, directBookExchange.getBookRequested());
    updateExchangeDetails(directBookExchange, bookRequestedInExchange);
    bookExchangeDao.saveBookExchange(directBookExchange);
    notificationsDao.saveNotification(
        new Notification.NotificationBuilder()
            .setMessage(exchangeAccepted)
            .setUserNotified(bookRequestedInExchange.getPostedBy())
            .setNotificationType(NotificationType.DIRECT_EXCHANGE_ACCEPTED)
            .setDateCreated(LocalDateTime.now())
            .build());
  }