diff --git a/TeamDBAwesome/TeamDBAwesome/js/homeController.js b/TeamDBAwesome/TeamDBAwesome/js/homeController.js index 30b20ee..5ed7a21 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/homeController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/homeController.js @@ -1,4 +1,4 @@ -angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope) { +angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope,HolderService) { /* BEGIN FUNCTIONS FUNCTIONS */ @@ -25,28 +25,10 @@ angular.module('routerApp').controller('homeController', function ($scope, $http // Function to register new users. $scope.createUser = function (newUser) { // TODO: Make Service fit into things. - var sub = { - FName: null, - LName: null, - Address: null, - City: null, - State: null, - Post: null, - Country: null, - Phone: null, - Fax: null, - Email: null, - Company: null, - //SUPPORT REP ID SHOULD BE 0 for NEW customer - SupportRepID: null, - PersonID: null, - CustomerID: null - }; - + var sub = HolderService.getBlankCustomer(); if (newUser.company == null) { newUser.company = null; } - sub.FName = newUser.firstName; sub.LName = newUser.lastName; sub.Address = newUser.addr; @@ -61,31 +43,20 @@ angular.module('routerApp').controller('homeController', function ($scope, $http sub.SupportRepID = 0; console.log(sub); - //Unsure of how to handle local host for now - /* - $http.post("http://localhost:3306/api/NewCustomer",sub) - .success(function (data, status, headers, config) { - $scope.messages = 'You are now registered and may now log in. '; - - }) - .error(function (data, status, headers, config) { - $scope.messages = 'There was a network error. Try again later.'; - });*/ var promise = $http({ method: "post", - url: "http://localhost:3306/api/NewCustomer", + url: "http://localhost:50031/api/NewCustomer", headers: { contentType: "application/json" }, data: sub }). success(function (data, status, headers, config) { - alert("success"); + $scope.messages = 'You are now registered and may now log in. '; }). error(function (error, status, headers, config) { - //alert("failure"); - console.log(error); + $scope.messages = 'There was a network error. Try again later.'; }); } diff --git a/TeamDBAwesome/TeamDBAwesome/js/userController.js b/TeamDBAwesome/TeamDBAwesome/js/userController.js index 8aaf6b9..d9a71d8 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/userController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/userController.js @@ -1,39 +1,70 @@ // The user controller will deal with -angular.module('routerApp').controller('userController', function($q,$window, $scope,$state, $stateParams, $location, $http, $cookies, urlService,$rootScope) { - /* Retrieve Url */ - var url = urlService.web; - $location.hash("top"); - $scope.COOKIE = $cookies.getAll(); +angular.module('routerApp').controller('userController', function ($q, $window, $scope, $state, $stateParams, $location, $http, $cookies, urlService, $rootScope, HolderService) { + /* Retrieve Url */ + var url = urlService.web; + $location.hash("top"); + $scope.COOKIE = $cookies.getAll(); - /* Begin Function Definitions */ - $scope.authenticateUser = function(id,pass){ - return $q(function(resolve,reject){ - var param = id + " " + pass; - var promise = $http.post(url + "/authenticateUser",param) - .success(function(data,status) { - console.log(data); - if (data.STATUS == 555) { - $scope.authenticated = false; - resolve('We did it'); - } else { - $scope.authenticated = true; - resolve('We did it'); - } - }) - .error(function(data, status, headers, config) { - $scope.messages = 'There was a network error. Try again later.'; - reject('We did not do it'); - }); - }) - } + // Customer Information Editing + // Retrieve Data + $scope.getUserInfo = function () { + var customerid = 1; + $scope.user = {}; + $http.get("http://localhost:50031/api/GetCustomer?PersonID=" + customerid) + .success(function (response) { + $scope.user = angular.copy(response); + console.log($scope.user); + console.log(response); + }) + } + // Update User Information + $scope.updateUser = function () { + console.log("Update User"); + var promise = $http({ + method: "post", + url: "http://localhost:50031/api/NewCustomer", + headers: { + contentType: "application/json" + }, + data: $scope.user + }). + success(function (data, status, headers, config) { + $scope.messages = 'You are now registered and may now log in. '; + }). + error(function (error, status, headers, config) { + $scope.messages = 'There was a network error. Try again later.'; + }); + } - $scope.logout = function(){ - $scope.messages = 'You have been logged out.'; - $cookies.remove("PWD"); - $cookies.remove("DEPID"); - $cookies.remove('LOGIN'); - $state.go('user'); - } + /* Begin Function Definitions */ + $scope.authenticateUser = function (id, pass) { + return $q(function (resolve, reject) { + var param = id + " " + pass; + var promise = $http.post(url + "/authenticateUser", param) + .success(function (data, status) { + console.log(data); + if (data.STATUS == 555) { + $scope.authenticated = false; + resolve('We did it'); + } else { + $scope.authenticated = true; + resolve('We did it'); + } + }) + .error(function (data, status, headers, config) { + $scope.messages = 'There was a network error. Try again later.'; + reject('We did not do it'); + }); + }) + } + + $scope.logout = function () { + $scope.messages = 'You have been logged out.'; + $cookies.remove("PWD"); + $cookies.remove("DEPID"); + $cookies.remove('LOGIN'); + $state.go('user'); + } $scope.myData = [ { @@ -54,10 +85,10 @@ angular.module('routerApp').controller('userController', function($q,$window, $s "company": "Fuelton", "employed": false } -]; + ]; - /* End Function Definitions */ + /* End Function Definitions */ - /* Begin Logic */ + /* Begin Logic */ }); \ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/pages/user-account.html b/TeamDBAwesome/TeamDBAwesome/pages/user-account.html index db4892a..5605bb0 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/user-account.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/user-account.html @@ -1,6 +1,67 @@ -
+
-

Account Settings Change here

-
+
+

Your Account Information

+
{{messages}}
+
+
+ + + First name is required +
+
+ + + Last name is required +
+
+ + + Address is required +
+
+ + + City is required +
+
+ + + State is required +
+
+ + + Country is required +
+
+ + + Postal is required +
+
+ + + Phone number is required +
+
+ + + Fax number is required +
+
+ + + Email is required +
+
+ + +
+
+ +
+
+