/**
 * Created by fran lopez on 8/12/15.
 */

    /**
     * AngularJS controller for book images AngularJS module. This
     * controller should be able to provide you with all the methods
     * needed to perform CRU operations.
     */

    angular.module('bookImages').controller('BookImagesController',
        ['$scope', '$routeParams', '$location', 'BookImagesByBookID',
            function ($scope, $routeParams, $location,
                      BookImagesByBookID) {

                /**
                 * This method will retrieve a list of book images
                 * based on the "bookId" route parameter, which the
                 * function obtains directly from the URL.
                 *
                 * "bookId" route parameter stores information of
                 * an identifier associated to a film saved in
                 * database.
                 *
                 * The "bookID" parameter is used to include in the
                 * view scope, to return to the preview view.
                 * Furthermore, the parameter is used to call a
                 * AngularJS service, which provides information of
                 * book images associated to a book related to the
                 * parameter.
                 *
                 * This method use a HTTP GET request to execute the
                 * operation.
                 */

                $scope.find = function() {

                    $scope.bookId       = $routeParams.bookId;
                    $scope.bookImages   = BookImagesByBookID.query({
                        bookId: $routeParams.bookId
                    });
                };
            }
        ]
    );