update-user.service.js
6.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
"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