Example #1
0
        public HttpResponseMessage GetAllLibraryBooksForACategory(LibraryBookCategory category)
        {
            var libraryService = new LibraryService();

            IEnumerable<ILibraryBook> books = libraryService.AllBooks(category);

            return Request.CreateResponse(HttpStatusCode.OK, books);
        }
Example #2
0
        public HttpResponseMessage GetAllLibraryBooks()
        {
            var libraryService = new LibraryService();

            IList<ILibraryBook> books = libraryService.AllBooks();

            return Request.CreateResponse(HttpStatusCode.OK, books);
        }
Example #3
0
        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);
        }