/// <summary> /// Checks whether a book can be borrowed or not /// </summary> /// <param name="bookId">book Id</param> /// <returns>Returns true if book can be borrowed, else false</returns> public bool CanAssignBook(int bookId) { // Check if any one has already borrowed the book var borrowedBook = _borrowDetailsRepository.Find(bookId); if (borrowedBook == null) { // Check if the book is available in library var validBook = _booksRepository.Find(bookId); if (validBook != null) { return(true); } } return(false); }
/// <summary> /// Checks whether a book can be renewed or not /// </summary> /// <param name="bookId">book Id</param> /// <returns>Returns true if book can be renewed, else false</returns> public bool CanRenewBook(int bookId) { var borrowedBook = _borrowDetailsRepository.Find(bookId); return(borrowedBook != null); }