From 10e06014cf604bb0dd38eb2519539cb6126adaaf Mon Sep 17 00:00:00 2001 From: Anish Date: Fri, 4 Oct 2024 19:58:47 +0530 Subject: [PATCH] borrowingService changes --- .../borrowing/BorrowingService.java | 36 +------------------ 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/src/main/java/com/libraryman_api/borrowing/BorrowingService.java b/src/main/java/com/libraryman_api/borrowing/BorrowingService.java index 003ef51..c65fe14 100644 --- a/src/main/java/com/libraryman_api/borrowing/BorrowingService.java +++ b/src/main/java/com/libraryman_api/borrowing/BorrowingService.java @@ -99,30 +99,7 @@ public Optional getBorrowingById(int borrowingId) { * @return the saved borrowing record * @throws ResourceNotFoundException if the book is not found or if there are not enough copies available */ -// @Transactional -// public synchronized BorrowingsDto borrowBook(BorrowingsDto borrowingDto) { -// Optional bookDtoOptional = bookService.getBookById(borrowingDto.getBook().getBookId()); -// -// if (bookDtoOptional.isPresent()) { -//// Book bookEntity = mapper.map(bookDtoOptional.get(), Book.class); -// BookDto bookDto = bookDtoOptional.get(); -// if (bookDto.getCopiesAvailable() > 0) { -// updateBookCopies(borrowingDto.getBook().getBookId(), "REMOVE", 1); -// borrowingDto.setBorrowDate(new Date()); -// borrowingDto.setDueDate(calculateDueDate()); -// Borrowings borrowing = mapper.map(borrowingDto, Borrowings.class); -// Borrowings savedBorrowing = borrowingRepository.save(borrowing); -// -// notificationService.borrowBookNotification(savedBorrowing); // Null Book problem -// notificationService.reminderNotification(savedBorrowing); // send this notification two days before the due date // Null Book problem -// return mapper.map(savedBorrowing,BorrowingsDto.class); -// } else { -// throw new ResourceNotFoundException("Not enough copies available"); -// } -// } else { -// throw new ResourceNotFoundException("Book not found"); -// } -// } // previous one + @Transactional public synchronized BorrowingsDto borrowBook(BorrowingsDto borrowingDto) { // Retrieve the book by its ID from the borrowingDto @@ -180,17 +157,6 @@ public synchronized BorrowingsDto borrowBook(BorrowingsDto borrowingDto) { } - - - - - - - - - - - /** * Manages the return process for a borrowed book. *