public IActionResult Transactions() { User currentUser = CurrentUser(); TempData["CurrentUser"] = currentUser.Id; // grab all loans user is involved in, both sides List <Loan> userLoans = _libraryDB.Loans.Where(x => x.BookLoaner == currentUser.Id || x.BookOwner == currentUser.Id).ToList(); //------- List <LoanRating> userLoansMoreInfo = new List <LoanRating>(); foreach (Loan loan in userLoans) { //Create loan review object to pass to view LoanRating l = new LoanRating(); //assign current user to LoanRating object l.currentUser = currentUser; l.loan = loan; //find book for bookInfo Book book = _libraryDB.Books.Find(loan.BookId); BookInfo apibook = _libraryDAL.GetBookInfo(book.TitleIdApi); l.ApiBook = apibook; if (loan.BookOwner == currentUser.Id) { l.otherUser = _libraryDB.Users.Find(loan.BookLoaner); } else { l.otherUser = _libraryDB.Users.Find(loan.BookOwner); } l.otherEmail = _libraryDB.AspNetUsers.Find(l.otherUser.UserId).UserName; userLoansMoreInfo.Add(l); } return(View(userLoansMoreInfo)); }