AIA.factory('AuthenticationService', function ($http, $q, $rootScope, LoginConstants, AIAConstants) { return { authenticateUser: function (userInfo) { var deferred = $q.defer(); $http.post('/API/api/Authenticate', JSON.stringify(userInfo), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $rootScope.LoginEnableUI(); $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, UserLicenseExportImage: function (imageDetails) { var deferred = $q.defer(); $http.post('/API/api/ExportImage', JSON.stringify(imageDetails), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $('#errorMessage').text( data); $("#messageModal").modal('show'); }); return deferred.promise; }, ByPassLoginToOpenModule: function (urlDetail) { var deferred = $q.defer(); $http.post('/API/api/ByPassLoginToOpenModule', JSON.stringify(urlDetail), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') $rootScope.isVisibleLogin = true; $rootScope.LoginEnableUI(); deferred.reject(data); $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, ManageUserLoginStatus: function (logindata) { var deferred = $q.defer();//userId tagName $http.post('/API/api/ManageUserLoginStatus', JSON.stringify(logindata), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { //console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); }); return deferred.promise; }, saveSetings: function (settings) { var deferred = $q.defer(); $http.post('/API/api/SaveUserSettings', JSON.stringify(settings), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $('#setting-spinner').css('visibility', 'hidden'); $('#modal-settings').css("display", "none"); $('#modelsettingsbackground').css('zIndex', '12000000'); $("#modelsettingsbackground").css("display", "none"); $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, saveAnimationVideo: function (vidData) { var deferred = $q.defer(); $http.post('/API/api/saveAnimationVideo', JSON.stringify(vidData), { headers: { 'Content-Type': 'application/json' }, uploadEventHandlers: { progress: function(e) { deferred.notify(e.loaded * 100 / e.total); }} }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); }); return deferred.promise; }, GetAodCoursesList: function (licenseId) { var deferred = $q.defer(); $http({ url: "/API/api/GetAodCoursesList", method: "GET", params: { LicenseId: licenseId } }) .success(function (data, status, headers, config) { deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, validateClientSite: function (clientInfo) { var deferred = $q.defer(); $http.post('/API/api/Client', JSON.stringify(clientInfo), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $rootScope.LoginEnableUI(); $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, validateUrlLogin: function (urlInfo) { var deferred = $q.defer(); $http.post('/API/api/UrlLogin', JSON.stringify(urlInfo), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $rootScope.LoginEnableUI(); $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, SendMailToUser: function (userInfo, havePassword) { var deferred = $q.defer(); $http.post('/API/api/ForgotUser', userInfo, { //JSON.stringify(userEmail) headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success'); deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, ResetUserPassword: function (userInfo) { var deferred = $q.defer(); $http.post('/API/api/ResetPassword', JSON.stringify(userInfo), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, UpdateLicenseTerm: function (licenseeAccountNumber) { var deferred = $q.defer(); $http.post('/API/api/LicenseTermCondition', JSON.stringify(licenseeAccountNumber), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, UnblockUser: function (userEmailId) { var deferred = $q.defer(); $http.post('/API/api/UnblockUser', JSON.stringify(userEmailId), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $('#errorMessage').text(data); $("#messageModal").modal('show'); }); return deferred.promise; }, getCofigValue: function() { var deferred = $q.defer(); $http({ method: 'GET', url: 'API/api/Configuration/GetConfigurationvalues' }).success(function (data, status, headers, config) { console.log('success' + data); deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); }); return deferred.promise; } } });