Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add payment ready to be tested. Login checks made for client.
  • Loading branch information
adl13006 committed Dec 2, 2015
1 parent 586c2df commit be7c2bc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 31 deletions.
35 changes: 27 additions & 8 deletions TeamDBAwesome/TeamDBAwesome/js/homeController.js
@@ -1,4 +1,4 @@
angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope,HolderService) {
angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope, HolderService) {

/* BEGIN FUNCTIONS FUNCTIONS */

Expand Down Expand Up @@ -41,16 +41,35 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
}

$scope.toAdminPage = function (user) {
$cookies.put('userid', user.username);
console.log($cookies.get('userid'));
$state.go('admin-home');
// 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) {
$cookies.put("userid", user.username);
console.log($cookies.get('userid'));
$state.go('user-home');

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) {
console.log(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 */
Expand Down
46 changes: 26 additions & 20 deletions TeamDBAwesome/TeamDBAwesome/js/userController.js
Expand Up @@ -7,8 +7,8 @@ angular.module('routerApp').controller('userController', function ($q, $window,

// Logging out
$scope.logout = function () {
cookies.remove('userid');
$state.go('user-home');
$cookies.remove('userid');
$state.go('home');
console.log("Happening");
}

Expand Down Expand Up @@ -47,24 +47,38 @@ angular.module('routerApp').controller('userController', function ($q, $window,
var pay = HolderService.getBlankPayment();
console.log(data);
pay.Type = data.type;
pay.default = 0;
pay.CustomerId = $cookies.get('userid');
pay.token = data.token;
pay.email = data.email;
pay.cardnum = data.num
pay.expr_date = data.expr_date;
pay.is_default = data.default;
if ( data.token != undefined) pay.token = data.token;
if (data.email != undefined) pay.email = data.email;
if ( data.num != undefined) pay.cardnum = data.num
if ( data.date != undefined) pay.expr_date = data.date;
if (data.default != undefined) pay.is_default = data.default;
var promise = $http({
method: "post",
url: "http://localhost:50031/api/AddPayment",
headers: {
contentType: "application/json"
},
data: pay
}).
success(function (data, status, headers, config) {
$scope.messages = 'You have successfully updated your information. ';
}).
error(function (error, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.';
});
console.log(pay);

}

// Dealing with Search
$scope.columns = [
{ field: 'TrackId', displayName: ' ', cellTemplate: '<center><button data-ng-click="addToCart(12)" class="btn btn-success btn-xs">Purchase</button></center></td>' },
{ field: 'TrackName', displayName: ' Track Name'},
{ field: 'AlbumTitle', displayName: ' Album Title '},
{ field: 'TrackName', displayName: ' Track Name' },
{ field: 'AlbumTitle', displayName: ' Album Title ' },
{ field: 'MediaType', displayName: ' Media Type ' },
{ field: 'Genre', displayName: ' Genre ' },
{ field: 'Clip', displayName: ' Sound Clip '},
{ field: 'Clip', displayName: ' Sound Clip ' },
{ field: 'UnitPrice', displayName: ' Unit Price ' }
];

Expand All @@ -74,7 +88,7 @@ angular.module('routerApp').controller('userController', function ($q, $window,
columnDefs: $scope.columns,
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
var cellTemplate = 'ui-grid/selectionRowHeader';
var cellTemplate = 'ui-grid/selectionRowHeader';
$scope.gridApi.core.addRowHeaderColumn({ name: 'rowHeaderCol', displayName: '', width: 30, cellTemplate: cellTemplate });
}
};
Expand Down Expand Up @@ -116,14 +130,6 @@ angular.module('routerApp').controller('userController', function ($q, $window,
console.log(trackid);
}

$scope.logout = function () {
$scope.messages = 'You have been logged out.';
$cookies.remove("PWD");
$cookies.remove("DEPID");
$cookies.remove('LOGIN');
$state.go('user');
}

$scope.myData = [
{
"firstName": "Cox",
Expand Down
2 changes: 1 addition & 1 deletion TeamDBAwesome/TeamDBAwesome/pages/partial-adminlogin.html
@@ -1,6 +1,6 @@
<div ng-controller='homeController'>
<div class="text-center">
<h1>Please sign in</h1>
<h1>Please sign in</h1> user 64
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
Expand Down
4 changes: 2 additions & 2 deletions TeamDBAwesome/TeamDBAwesome/pages/partial-login.html
Expand Up @@ -2,14 +2,14 @@
<div class="row">
<div ng-controller='homeController'>
<div class="text-center">
<h1>Please sign in</h1>
<h1>Please sign in</h1> use user 1
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<div id="messages" class="alert alert-info" data-ng-show="messages" data-ng-bind="messages"></div>
<input ng-model="user.username" class="form-control" placeholder="Username" required="" autofocus="">
<input type="password" ng-model="user.password" class="form-control" placeholder="Password" required="">

<a ng-disabled="!(user.username && user.password)" type="submit" class="btn btn-lg btn-primary center-block" ng-click="toUserPage(user)">Submit</a>
</div>

Expand Down

0 comments on commit be7c2bc

Please sign in to comment.