Add user management
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
(function () {
|
||||
window.app.factory('userSvc',
|
||||
function($http) {
|
||||
var users = [];
|
||||
|
||||
loadUsers();
|
||||
|
||||
var svc = {
|
||||
create: create,
|
||||
edit: edit,
|
||||
users: users,
|
||||
exportusers: exportusers
|
||||
};
|
||||
|
||||
return svc;
|
||||
|
||||
function loadUsers() {
|
||||
$http.post('/User/All')
|
||||
.success(function(data) {
|
||||
users.addRange(data);
|
||||
});
|
||||
}
|
||||
|
||||
function exportusers() {
|
||||
return $http.post('/User/Export', {}, { responseType: 'arraybuffer' });
|
||||
}
|
||||
|
||||
function create(user) {
|
||||
return $http.post('/User/Create', user)
|
||||
.success(function(user) {
|
||||
users.unshift(user);
|
||||
});
|
||||
}
|
||||
|
||||
function edit(existingUser, editedUser) {
|
||||
return $http.post('/User/Edit', editedUser)
|
||||
.success(function(user) {
|
||||
angular.copy(user, existingUser);
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user