'use strict';

var TaxListCtrl = ['$scope', 'taxes', function ($scope, taxes) {
    $scope.info = taxes;
}];

TaxListCtrl.resolve = {
    taxes: ['Tax', function (Tax) {
        return Tax.query({}).$promise;
    }]
};

var TaxCtrl = ['$scope', '$routeParams', '$location', 'tax', function ($scope, $routeParams, $location, tax) {
    $scope.tax = tax;

    $scope.save = function () {
        $scope.tax.$save(function (u, putResponseHeaders) {
            $scope.$emit('notification',{Type: 'Success', Message: ''});
            $location.path('/Taxes')
        }, function (data, status) {
            $scope.$emit('notification',{Type: 'Danger', Message: data.data});
        });
    };

    $scope.delete = function () {
        $scope.tax.$delete(function (u, putResponseHeaders) {
            $scope.$emit('notification',{Type: 'Success', Message: ''});
            $location.path('/Taxes')
        }, function (data, status) {
            $scope.$emit('notification',{Type: 'Danger', Message: data.data});
        });
    };
    $('#txtName').focus();
}];

TaxCtrl.resolve = {
    tax: ['$route', 'Tax', function ($route, Tax) {
        var id = $route.current.params.id;
        return Tax.get({id: id}).$promise;
    }]
};
