{"size": 1477, "ext": "js", "max_stars_repo_path": "public/modules/venues/controllers/venues.client.controller.js", "max_stars_repo_name": "doverphone/g4g-setlist", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/modules/venues/controllers/venues.client.controller.js", "max_issues_repo_name": "doverphone/g4g-setlist", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/modules/venues/controllers/venues.client.controller.js", "max_forks_repo_name": "doverphone/g4g-setlist", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.3787878788, "max_line_length": 123, "alphanum_fraction": 0.6018957346}
'use strict';

// Venues controller
angular.module('venues').controller('VenuesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Venues',
	function($scope, $stateParams, $location, Authentication, Venues) {
		$scope.authentication = Authentication;

		// Create new Venue
		$scope.create = function() {
			// Create new Venue object
			var venue = new Venues ({
				name: this.name
			});

			// Redirect after save
			venue.$save(function(response) {
				$location.path('venues/' + response._id);

				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Remove existing Venue
		$scope.remove = function(venue) {
			if ( venue ) { 
				venue.$remove();

				for (var i in $scope.venues) {
					if ($scope.venues [i] === venue) {
						$scope.venues.splice(i, 1);
					}
				}
			} else {
				$scope.venue.$remove(function() {
					$location.path('venues');
				});
			}
		};

		// Update existing Venue
		$scope.update = function() {
			var venue = $scope.venue;

			venue.$update(function() {
				$location.path('venues/' + venue._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Venues
		$scope.find = function() {
			$scope.venues = Venues.query();
		};

		// Find existing Venue
		$scope.findOne = function() {
			$scope.venue = Venues.get({ 
				venueId: $stateParams.venueId
			});
		};
	}
]);