// GET: Library public ActionResult Index() { string userId = GetUserId(); var currentUser = repo.GetUser(userId); ViewBag.UserRole = currentUser.role; var booksLentData = repo.GetBooksLent(userId); List <BooksLent> booksLentList = new List <BooksLent>(); foreach (var item in booksLentData) { if (item.return_time == null) { booksLentList.Add(new BooksLent() { LentId = item.lend_id, BookName = repo.GetBookNameByCopyId(item.copy_id), BorrowTime = item.lend_time, ExpireTime = item.expire_time, IsChecked = false }); } } return(View(booksLentList)); }