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

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

    angular.module('tvSerieTrailers').controller('TVSerieTrailersController',
        ['$scope', '$routeParams', '$location', 'TVSerieTrailersByTVSerieID',
            function ($scope, $routeParams, $location,
                      TVSerieTrailersByTVSerieID) {

                /**
                 * This method will retrieve a list of tv serie
                 * trailers based on the "TVSerieId" route parameter,
                 * which the function obtains directly from the URL.
                 *
                 * "TVSerieId" route parameter stores information of
                 * an identifier associated to a tv serie saved in
                 * database.
                 *
                 * The "TVSerieID" 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 tv serie trailers
                 * associated to a tv serie related to the parameter.
                 *
                 * This method use a HTTP GET request to execute the
                 * operation.
                 */

                $scope.find = function() {

                    $scope.TVSerieId       = $routeParams.TVSerieId;
                    $scope.tvSerieTrailers = TVSerieTrailersByTVSerieID.query({
                        TVSerieId: $routeParams.TVSerieId
                    });
                };
            }
        ]
    );