"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@angular/core");
const http_1 = require("@angular/http");
require("rxjs/add/operator/toPromise");
require("rxjs/add/operator/map");
let DataService = class DataService {
    constructor(http) {
        this.http = http;
        this.headers = new http_1.Headers({ 'Content-Type': 'application/json', 'charset': 'UTF-8' });
        this.options = new http_1.RequestOptions({ headers: this.headers });
    }
    //VISIT service//
    addVisit(obj) {
        return this.http.post('/addvisit', obj).map(res => res.json());
    }
    viewVisit() {
        return this.http.get('/agenda', {}).map(res => res.json());
    }
    updateVisit(agenda) {
        return this.http.post('/updateagenda', agenda).map(res => res.json());
    }
    getVisitById(id) {
        return this.http.post('/getagendabyid', { "visit_id": id }).map(res => res.json());
    }
    deleteVisit(agenda) {
        return this.http.post('/deleteagenda', { _id: agenda['_id'] }).map(res => res);
    }
    //Agenda
    addAgenda(obj) {
        return this.http.post('/saveAgenda', obj).map(res => res.json());
    }
    updateAgenda(obj) {
        return this.http.post('/updateagn', obj).map(res => res.json());
    }
    deleteAgenda(obj) {
        return this.http.post('/deleteagn', obj).map(res => res.json());
    }
    getAgenda(visit_id) {
        return this.http.post('/agendaDls', { "visit_id": visit_id }).map(res => res.json());
    }
    //customer service
    addCustomer(obj) {
        return this.http.post('/savecustomer', obj).map(res => res.json());
    }
    updateCustomer(obj) {
        return this.http.post('/updatecustomer', obj).map(res => res.json());
    }
    deleteCustomer(customer_id) {
        return this.http.post('/deletecustomer', { "customer_id": customer_id }).map(res => res.json());
    }
    //presenter service
    addPresenter(obj) {
        return this.http.post('/savepresenter', obj).map(res => res.json());
    }
    updatePresenter(obj) {
        return this.http.post('/updatepresenter', obj).map(res => res.json());
    }
    deletePresenter(obj) {
        return this.http.post('/deletepresenter', obj).map(res => res.json());
    }
    //event service
    addEvent(obj) {
        return this.http.post('/saveevent', obj).map(res => res.json());
    }
    getEvents(visit_id) {
        return this.http.post('/getevents', { "visit_id": visit_id }).map(res => res.json());
    }
    updateEvents(obj) {
        return this.http.post('/updateevent', obj).map(res => res.json());
    }
    updateEvent(obj) {
        return this.http.post('/updateevent', obj).map(res => res.json());
    }
    deleteEvent(obj) {
        return this.http.post('/deleteevent', obj).map(res => res.json());
    }
    //Participant
    addParticipant(obj) {
        return this.http.post('/saveparticipant', obj).map(res => res.json());
    }
    updateParticipant(obj) {
        return this.http.post('/updateparticipant', obj).map(res => res.json());
    }
    deleteParticipant(obj) {
        return this.http.post('/deleteparticipant', obj).map(res => res.json());
    }
    getParticipantByEventId(obj) {
        return this.http.post('/getParticipantByEventId', obj).map(res => res.json());
    }
    //feedback
    saveFeedback(obj) {
        return this.http.post('/saveFeedback', obj).map(res => res.json());
    }
    //login service
    login(obj) {
        return this.http.post('/login', JSON.stringify(obj), this.options)
            .map((res) => {
            let data = res.json();
            if (Object.keys(data)[0] !== 'message') {
                localStorage.setItem("currentUser", JSON.stringify(data));
            }
            return data;
        });
    }
    logout() {
        localStorage.removeItem('currentUser');
    }
};
DataService = __decorate([
    core_1.Injectable(),
    __metadata("design:paramtypes", [http_1.Http])
], DataService);
exports.DataService = DataService;
//# sourceMappingURL=data.service.js.map