private void updateExchangeDetails( DirectBookExchange directBookExchange, Book bookRequestedInExchange) { directBookExchange.setBookOfferedInExchange(bookRequestedInExchange); directBookExchange.setOver(true); directBookExchange.setSuccessful(true); directBookExchange.setDateCompleted(LocalDateTime.now()); }
private void notifyOtherExchangeParticipant( String userEmail, DirectBookExchange directExchangeToReject) { if (directExchangeToReject.getExchangeInitiatorEmail().equals(userEmail)) { raiseDirectExchangeRejectedNotification( excahngeRejecteUserUnderOfferdMessage, directExchangeToReject.getUserUnderOffer()); } else { raiseDirectExchangeRejectedNotification( exchangeRejectedInitiatorMessage, directExchangeToReject.getExchangeInitiator()); } }
public void rejectDirectExchange(String userEmail, int id) throws BookExchangeInternalException { DirectBookExchange directExchangeToReject = bookExchangeDao .getDirectBookExchange(id) .orElseThrow(() -> new BookExchangeInternalException("No exchange found")); directExchangeToReject.setOver(true); directExchangeToReject.setSuccessful(false); directExchangeToReject.setDateCompleted(LocalDateTime.now()); bookExchangeDao.saveBookExchange(directExchangeToReject); notifyOtherExchangeParticipant(userEmail, directExchangeToReject); }
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()); }