Skip to content

Commit

Permalink
Fixed BCRL creation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Tanner authored and Tyler Tanner committed Oct 28, 2022
1 parent 73c074b commit fa398dd
Showing 1 changed file with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.skilldistillery.jpaclubindex.data.UserDAO;
import com.skilldistillery.jpaclubindex.data.UserRLDAO;
import com.skilldistillery.jpaclubindex.entities.Book;
import com.skilldistillery.jpaclubindex.entities.BookClub;
import com.skilldistillery.jpaclubindex.entities.BookClubReadingList;
import com.skilldistillery.jpaclubindex.entities.User;
import com.skilldistillery.jpaclubindex.entities.UserReadingList;
Expand Down Expand Up @@ -63,35 +64,23 @@ public String createReadingList(HttpSession session) {

@RequestMapping(path="createReadingList.do", params = "bookClubId", method=RequestMethod.POST)
public String createBCRL(HttpSession session, BookClubReadingList bcrl, String firstBook, int bookClubId) {
BookClub bc = bcDao.getBookClubById(bookClubId);

bcrl.addBook(bookDao.findBookByTitle(firstBook).get(0));
bcrl.setBookClub(bcDao.getBookClubById(bookClubId));
bcrl.setBookClub(bc);
bc.addReadingList(bcrl);

bcrl = bcrlDao.createBCRL(bcrl);

session.setAttribute("bookClub", bcDao.getBookClubById(bookClubId));
session.setAttribute("bookClub", bc);
return "redirect:createdBCRL.do";
}

@RequestMapping(path="createdBCRL.do")
public String createdBCRL(HttpSession session) {
return "bookclub/bookClub";
}

// @RequestMapping(path="createReadingList.do", params = "userId", method=RequestMethod.POST)
// public String createUserRL(HttpSession session, UserReadingList uRL, String firstBook, int userId) {
// uRL.addBook(bookDao.findBookByTitle(firstBook).get(0));
// uRL.setUser(userDao.findUserById(userId));
//
// uRL = userRLDao.createUserRL(uRL);
//
// User user = userDao.findUserById(userId);
// user.setBookClubs(bcDao.getBookClubsByUser(user));
//
// session.setAttribute("user", user);
//
// return "redirect:createdURL.do";
// }


@RequestMapping(path="createReadingList.do", params = "userId", method=RequestMethod.POST)
public String createUserRL(HttpSession session, UserReadingList uRL, String firstBook, int userId) {
User user = userDao.findUserById(userId);
Expand Down

0 comments on commit fa398dd

Please sign in to comment.