System.register(["@angular/http", "rxjs/Rx", "@angular/core"], function (exports_1, context_1) {
    "use strict";
    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var __metadata = (this && this.__metadata) || function (k, v) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
    };
    var __moduleName = context_1 && context_1.id;
    var http_1, Rx_1, core_1, CustomerAjaxService;
    return {
        setters: [
            function (http_1_1) {
                http_1 = http_1_1;
            },
            function (Rx_1_1) {
                Rx_1 = Rx_1_1;
            },
            function (core_1_1) {
                core_1 = core_1_1;
            }
        ],
        execute: function () {
            CustomerAjaxService = (function () {
                function CustomerAjaxService(http) {
                    this.http = http;
                }
                CustomerAjaxService.prototype.getCustomers = function () {
                    return this.http.get("http://localhost:61934/home/getcustomers")
                        .map(function (custs) {
                        var custBody = custs.json();
                        return custBody.data || {};
                    })
                        .catch(function (error) {
                        var errMsg;
                        if (error instanceof http_1.Response) {
                            var body = error.json() || '';
                            var err = body.error || JSON.stringify(body);
                            errMsg = error.status + " - " + (error.statusText || '') + " " + err;
                        }
                        else {
                            errMsg = error.message ? error.message : error.toString();
                        }
                        console.error(errMsg);
                        return Rx_1.Observable.throw(errMsg);
                    });
                };
                return CustomerAjaxService;
            }());
            CustomerAjaxService = __decorate([
                core_1.Injectable(),
                __metadata("design:paramtypes", [http_1.Http])
            ], CustomerAjaxService);
            exports_1("CustomerAjaxService", CustomerAjaxService);
        }
    };
});
//# sourceMappingURL=CustomerServices.js.map