"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 user_service_1 = require("./user.service"); var router_1 = require("@angular/router"); var forms_1 = require("@angular/forms"); var datamodel_1 = require("../UserEntity/datamodel"); var http_1 = require("@angular/http"); var confirm_service_1 = require("../../Shared/Confirm/confirm.service"); require("rxjs/Rx"); require("rxjs/add/operator/map"); require("rxjs/add/operator/filter"); var ChangeUserID = /** @class */ (function () { //@ViewChild("profileModal") //profileModal: ModalComponent; //errorMessage: any; function ChangeUserID(userservice, router, fb, http, _confirmService) { this.userservice = userservice; this.router = router; this.fb = fb; this.http = http; this._confirmService = _confirmService; this.UserId = 1; this.baseUrl = "User"; } ChangeUserID.prototype.ngOnInit = function () { this.user = new datamodel_1.User(); this.alerts = ''; //this.userservice.GetUserById(this.UserId); this.ChangeUserIdFrm = this.fb.group({ id: [''], loginid: ['', forms_1.Validators.required], newloginid: ['', [forms_1.Validators.required, forms_1.Validators.minLength(8)]], confirmloginid: ['', forms_1.Validators.required] // LastName: [''], // Gender: ['', Validators.required], // Email: [''] }); this.GetUserById(); }; ChangeUserID.prototype.GetUserById = function () { var _this = this; this.userservice.GetUserById() .subscribe(function (x) { console.log(x); _this.bindUsers(x); }, function (error) { return _this.error = error; }); }; ChangeUserID.prototype.UpdateUserId = function () { var _this = this; // debugger; this.alerts = ''; if (this.user.LoginId == this.ChangeUserIdFrm.value.newloginid) { this.alerts += '
New userid and old userid must be different'; } if (this.ChangeUserIdFrm.value.newloginid != this.ChangeUserIdFrm.value.confirmloginid) { this.alerts += '
New userid and confirm userid must be same'; } if (this.alerts == '') { this.user = this.ChangeUserIdFrm.value; //if(this.user.) console.log(this.user); var obj = this.user; if (this.ChangeUserIdFrm.valid) { return this.userservice.UpdateUserId(obj) .subscribe(function (n) { return (_this.AfterInsertData(n)); }, function (error) { return _this.error = error; }); } } }; ChangeUserID.prototype.AfterInsertData = function (data) { if (data == "success") { this._confirmService.activate("Userid Updated Successfully.", "alertMsg"); } else { this.alerts += '' + data + ''; return false; } //if (this.closeflag) { // this.close.emit(null); //} //else { //} }; ChangeUserID.prototype.bindUsers = function (data) { //console.log(data); //alert(JSON.stringify(data)); this.user = data[0]; console.log(this.user); this.ChangeUserIdFrm.controls['id'].setValue(this.user.Id); this.ChangeUserIdFrm.controls['loginid'].setValue(this.user.LoginId); this.ChangeUserIdFrm.controls['newloginid'].setValue(this.user.NewLoginId); this.ChangeUserIdFrm.controls['confirmloginid'].setValue(''); }; ChangeUserID.prototype.ResetFormFields = function () { this.ChangeUserIdFrm.reset(); this.ChangeUserIdFrm.controls['id'].setValue(this.user.Id); this.ChangeUserIdFrm.controls['loginid'].setValue(this.user.LoginId); this.ChangeUserIdFrm.controls['newloginid'].setValue(''); this.ChangeUserIdFrm.controls['confirmloginid'].setValue(''); this.alerts = ''; }; ChangeUserID = __decorate([ core_1.Component({ templateUrl: './changeuserid.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' }), __metadata("design:paramtypes", [user_service_1.UserService, router_1.Router, forms_1.FormBuilder, http_1.Http, confirm_service_1.ConfirmService]) ], ChangeUserID); return ChangeUserID; }()); exports.ChangeUserID = ChangeUserID; //# sourceMappingURL=changeuserid.component.js.map