"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 }); var core_1 = require("@angular/core"); var http_1 = require("@angular/http"); var router_1 = require("@angular/router"); var Observable_1 = require("rxjs/Observable"); require("rxjs/add/operator/map"); require("rxjs/add/operator/catch"); //import { AppSettings, User } from '../model/data-model'; var UpdateUserService = /** @class */ (function () { function UpdateUserService(http, router) { //if (this.currentUser == null) { // var user = localStorage.getItem("currentUser"); this.http = http; this.router = router; // if (user != null) { // this.currentUser = JSON.parse(user); // this.loggedIn = true; // } //} this.userId = 0; this.firstName = ""; this.lastName = ""; this.emailId = ""; } UpdateUserService.prototype.extractData = function (res) { var body = res.json(); return body || {}; }; UpdateUserService.prototype.handleError = function (error) { // In a real world app, we might use a remote logging infrastructure 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 Observable_1.Observable.throw(errMsg); }; UpdateUserService.prototype.UpdateUserProfile = function (applicationName, strFirstName, strLastName, strEmailID) { console.log('inside update-user service -2'); var usrID; usrID = 1; //let headers = new Headers({ 'Content-Type': 'application/json' }); var headers = new http_1.Headers(); headers.append('Content-type', 'application/x-www-form-urlencoded'); var options = new http_1.RequestOptions({ headers: headers }); var body = 'userId=' + usrID + '&emailId=' + strEmailID + '&firstName=' + strFirstName + '&lastName=' + strLastName; console.log(body); var urlSearchParams = new http_1.URLSearchParams(); urlSearchParams.append('userId', usrID.toString()); urlSearchParams.append('firstName', strFirstName); urlSearchParams.append('lastName', strLastName); urlSearchParams.append('emailId', strEmailID); var body2 = urlSearchParams.toString(); return this.http.post('http://localhost:85/AIAHTML5.Server/api/updateprofile', body, options) .map(function (response) { console.log(response); var body = response.json(); console.log(body); }) .catch(this.handleError); }; UpdateUserService.prototype.GetUserDetailsByIdandLoginId = function (id, loginId) { console.log('inside user-service getUserDetailsById'); debugger; var headers = new http_1.Headers(); headers.append('Content-Type', 'application/json'); //headers.append('Content-type', 'application/x-www-form-urlencoded'); var options = new http_1.RequestOptions({ headers: headers }); var params = new http_1.URLSearchParams(); params.append('iUserId', id.toString()); params.append('sLoginId', loginId); return this.http.get('http://localhost:85/AIAHTML5.Server/api/changeuserid', { headers: headers, search: params }) .map(this.extractData) .catch(this.handleError); }; UpdateUserService.prototype.UpdateUserId = function (id, newLoginId) { console.log('inside user-service updateUserId'); var headers = new http_1.Headers(); headers.append('Content-type', 'application/x-www-form-urlencoded'); var options = new http_1.RequestOptions({ headers: headers }); var params = new http_1.URLSearchParams(); params.append('iUserId', id.toString()); params.append('newLoginId', newLoginId); var body = params.toString(); return this.http.post('http://localhost:85/AIAHTML5.Server/api/changeuserid', body, options) .map(this.extractData) .catch(this.handleError); }; UpdateUserService.prototype.GetUserDetailsByLoginIdandPassword = function (loginId, password) { console.log('inside user-service getUserDetailsByLoginIdandPassword'); debugger; var headers = new http_1.Headers(); headers.append('Content-Type', 'application/json'); //headers.append('Content-type', 'application/x-www-form-urlencoded'); var options = new http_1.RequestOptions({ headers: headers }); var params = new http_1.URLSearchParams(); params.append('sLoginId', loginId); params.append('sPassword', password); return this.http.get('http://localhost:85/AIAHTML5.Server/api/changeuserpassword', { headers: headers, search: params }) .map(this.extractData) .catch(this.handleError); }; UpdateUserService.prototype.UpdateUserPassword = function (id, newPassword) { console.log('inside user-service UpdateUserPassword'); var headers = new http_1.Headers(); headers.append('Content-type', 'application/x-www-form-urlencoded'); var options = new http_1.RequestOptions({ headers: headers }); var params = new http_1.URLSearchParams(); params.append('iUserId', id.toString()); params.append('newPassword', newPassword); var body = params.toString(); return this.http.post('http://localhost:85/AIAHTML5.Server/api/changeuserpassword', body, options) .map(this.extractData) .catch(this.handleError); }; UpdateUserService = __decorate([ core_1.Injectable(), __metadata("design:paramtypes", [http_1.Http, router_1.Router]) ], UpdateUserService); return UpdateUserService; }()); exports.UpdateUserService = UpdateUserService; //# sourceMappingURL=update-user.service.js.map