package scareflix

import groovy.json.*

class SearchController {

    def index() {
        def baseUrl = "http://localhost:8001/movies/"
        def foundResults = false
        def resultsList

        // Get the search term
        def title = params.title
        def actor = params.actor

        // Perform the search
        if (title != null || actor != null) {
            def feedUrl

            // Construct the API request URL.
            if (title != null) {
                feedUrl = baseUrl + "title/" + title
            } else {
                feedUrl = baseUrl + "actor/" + actor
            }

            // Run the query and process its results
            def text = ("curl " + feedUrl).execute().text
            if (!text.equals("")) {
                resultsList = new JsonSlurper().parseText(text)
                foundResults = true
            }
        }

        [foundResults:foundResults, resultsList:resultsList]
    }
}

package scareflix

import groovy.json.*

class SearchController {

    def index() {
        def baseUrl = "http://localhost:8001/movies/"
        def foundResults = false
        def resultsList

        // Get the search term
        def title = params.title
        def actor = params.actor

        // Perform the search
        if (title != null || actor != null) {
            def feedUrl

            // Construct the API request URL.
            if (title != null) {
                feedUrl = baseUrl + "title/" + title
            } else {
                feedUrl = baseUrl + "actor/" + actor
            }

            // Run the query and process its results
            def text = ("curl " + feedUrl).execute().text
            if (!text.equals("")) {
                resultsList = new JsonSlurper().parseText(text)

                // Check if there were any results
                if (resultsList.size() > 0) {
                    foundResults = true
                }
            }
        }

        [foundResults:foundResults, resultsList:resultsList]
    }
}

Fix how empty results are handled
Fix how empty results are handled

Change the search results so that it displays an error message when no results are returned for a search.

Closes #1
