var couponApp = angular.module('fbeaztAdmin');

couponApp.controller('couponListCtrl', function ($route, $scope, $http, $routeParams, $window) {
    $scope.coupons = [];

    $scope.reloadCoupons = function () {
        $http.get('http://localhost:5000/api/coupon').success(function (d) {
            $scope.coupons = d;
        }).error(function (e) {
            console.error(e);
            alert(e);
        });
    };

    $scope.reloadCoupons();
})

couponApp.controller('couponDetailCtrl', function ($scope, $http, $routeParams, $location) {
    $scope.model = {};

    $http.get('http://localhost:5000/api/coupon/' + $routeParams.id).success(function (d) {
        if (!d){ d = {"status": true}}
        if (!d.id) {d.id = "-1";d.status=true;}
        if(d.start){
            d.start = new Date(d.start);
        }
        if(d.end){
            d.end = new Date(d.end);
        }
        $scope.model = d;
        console.log(d);
    }).error(function (e) {
        console.error(e);
        alert('Error while fetching coupon details');
        $location.path('/coupon');
    })

    $scope.save = function () {
        if ($scope.frmCoupon.$invalid) {
            alert("Form contains invalid data\n\nPlease check the form and submit again");
            return;
        }

        var item = angular.copy($scope.model);

        if (item.id == "-1") {
            item.id = null;
            res = $http.post('http://localhost:5000/api/coupon', item);
        } else {
            res = $http.put('http://localhost:5000/api/coupon/' + item.id, item);
        }

        res.success(function (data) {
            if (data.status == "success") {
                $location.path('/coupon');
            } else {
                alert(data.message);
            }
        }).error(function (e) {
            alert(e);
            console.error(e);
        })
    }
});
@@ -41,16 +41,191 @@
 min');%0A%0A
+function isLocalEnv() %7B%0A    return (window.location.host.match(/localhost/)) !== null;%0A%7D%0A%0Avar COUPON_URL = isLocalEnv() ? 'http://localhost:5000/api/coupon' : '/api/coupon';%0A%0A
 couponAp
@@ -402,42 +402,18 @@
 get(
-'http://localhost:5000/api/coupon'
+COUPON_URL
 ).su
@@ -736,41 +736,22 @@
 get(
-'http://localhost:5000/api/coupon
+COUPON_URL + '
 /' +
@@ -1552,42 +1552,18 @@
 ost(
-'http://localhost:5000/api/coupon'
+COUPON_URL
 , it
@@ -1616,41 +1616,22 @@
 put(
-'http://localhost:5000/api/coupon
+COUPON_URL + '
 /' +

fix coupon api url in admin page