Ejemplo n.º 1
0
        public JsonResult Search(string searchString)
        {
            var dbBooks = _bookService.Search(searchString).ToList();

            if (!dbBooks.Any())
            {
                return(ErrorResponse());
            }

            return(MultipleResults(BookViewModelHelpers.ConvertToViewModels(dbBooks)));
        }
        public JsonResult Search(string searchString)
        {
            if (string.IsNullOrWhiteSpace(searchString))
            {
                return(ErrorResponse("Search string cannot be empty"));
            }

            var books = _bookService.Search(searchString);

            if (!books.Any())
            {
                return(ErrorResponse("Cannot find any books with the provided search string"));
            }

            return(MultipleResults(BookViewModelHelpers.ConvertToViewModels(books.ToList())));
        }