Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TeamDbAwesome/TeamDBAwesome/TeamDBAwesome/js/homeController.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
78 lines (69 sloc)
2.6 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope, HolderService) { | |
/* BEGIN FUNCTIONS FUNCTIONS */ | |
// Function to register new users. | |
$scope.createUser = function (newUser) { | |
// TODO: Make Service fit into things. | |
var sub = HolderService.getBlankCustomer(); | |
if (newUser.company == null) { | |
newUser.company = null; | |
} | |
sub.FName = newUser.firstName; | |
sub.LName = newUser.lastName; | |
sub.Address = newUser.addr; | |
sub.City = newUser.city; | |
sub.State = newUser.state; | |
sub.Post = newUser.postal; | |
sub.Country = newUser.country; | |
sub.Phone = newUser.phone; | |
sub.Fax = newUser.fax; | |
sub.Email = newUser.email; | |
sub.Company = newUser.company; | |
sub.SupportRepID = 0; | |
console.log(sub); | |
var promise = $http({ | |
method: "post", | |
url: "http://localhost:50031/api/NewCustomer", | |
headers: { | |
contentType: "application/json" | |
}, | |
data: sub | |
}). | |
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.toAdminPage = function (user) { | |
// we need a get employee | |
if (!angular.isNumber(user.username)) $scope.messages = 'Please enter your person number'; | |
/* $http.get("http://localhost:50031/api/GetCustomer?PersonID=" + user.username) | |
.success(function (response) { | |
if (response.employeeID == null) { | |
$scope.messages = 'You have entered an incorrect Employee username'; | |
} | |
else {*/ | |
$cookies.put('userid', user.username); | |
console.log($cookies.get('userid')); | |
$state.go('admin-home'); | |
//} | |
//}) | |
} | |
$scope.toUserPage = function (user) { | |
$http.get("http://localhost:50031/api/GetCustomer?PersonID=" + user.username) | |
.success(function (response) { | |
if (response.CustomerID == null) { | |
$scope.messages = 'You have entered an incorrect User'; | |
} | |
else { | |
$cookies.put("userid", user.username); | |
console.log($cookies.get('userid')); | |
$state.go('user-home'); | |
} | |
}) | |
} | |
/* BEGIN LOGIC */ | |
var url = urlService.web; | |
/* END LOGIC */ | |
}); |