public HttpResponseMessage GetAllLibraryBooksForACategory(LibraryBookCategory category) { var libraryService = new LibraryService(); IEnumerable<ILibraryBook> books = libraryService.AllBooks(category); return Request.CreateResponse(HttpStatusCode.OK, books); }
public HttpResponseMessage GetAllLibraryBooks() { var libraryService = new LibraryService(); IList<ILibraryBook> books = libraryService.AllBooks(); return Request.CreateResponse(HttpStatusCode.OK, books); }
public HttpResponseMessage GetSortedLibraryBooks() { var libraryService = new LibraryService(); List<CategoryBookList> listOfCategories = new List<CategoryBookList>(); foreach (LibraryBookCategory category in Enum.GetValues(typeof(LibraryBookCategory))) { IEnumerable<ILibraryBook> books = libraryService.AllBooks(category); List<ILibraryBook> bookList = books.ToList<ILibraryBook>(); ILibraryBookFineCalculator calculator = new LibraryBookFineCalculator(); //create the object you will return to the client string categoryString = category.ToString(); CategoryBookList catBookList = new CategoryBookList(bookList, categoryString, calculator.CalculateTotalFine(DateTime.Now, bookList)); listOfCategories.Add(catBookList); } return Request.CreateResponse(HttpStatusCode.OK, listOfCategories); }