AIA.factory('LabExerciseService', function ($http, $q,$rootScope) { return { saveLabExerciseAttempt: function (labExercieObj) { var deferred = $q.defer(); $http.post('/API/api/LabExercise', JSON.stringify(labExercieObj), { headers: { 'Content-Type': 'application/json' } }) //$http.post('/API/api/LabExercise', JSON.stringify(labExercieObj, userId, labExerciseIdentifier, LastQuestion, TotalQuestions), { // 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.errorMessage = data; $("#messageModal").modal('show'); }); return deferred.promise; }, GetLabExercise: function (labExerciseInfo) { var deferred = $q.defer(); $http({ url: "/API/api/LabExercise", method: "GET", params: { userId: labExerciseInfo.userId, labExerciseIdentifier: labExerciseInfo.identifier } }) .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.errorMessage = data; $("#messageModal").modal('show'); }); return deferred.promise; }, // code of email report LabExerciseReport: function (User, reportImage) { User.reportImage = reportImage; var deferred = $q.defer(); debugger; // var jsonData = { 'EmailTo': User.EmailTo, 'EmailAdd': User.EmailAdd }; $http.post('http://192.168.90.19:91/API/api/LabExercise/SendEmail', JSON.stringify(User), { headers: { 'Content-Type': 'application/json' }, // data: { Users: JSON.stringify(jsonData) } }) .success(function (data, status, headers, config) { debugger; console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { debugger; console.log('error') deferred.reject(data); }); return deferred.promise; } } })