-
-
Save wesleycho/11118325 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if($scope.new_user_info.isLocation) | |
{ | |
if(!$scope.new_user_info.location_id) | |
{ | |
Location.create($scope.new_user_info.location).success(function(newLocation){ | |
$scope.new_user_info.location_id = newLocation.id; | |
$scope.new_location = {}; | |
successAddLocation = true; | |
}).error(function(data, status, header, config) { | |
if(status == 500) | |
{ | |
$scope.alerts.push({ type: 'danger', msg: "Unable to add new location" }); | |
return; | |
} | |
}); | |
} | |
} | |
if(successAddLocation) | |
{ | |
User.create($scope.new_user_info).success(function(newUser){ | |
$scope.allUsers.push(newUser); | |
$scope.new_user_info = {}; | |
if($scope.new_user_info.isLocation) | |
{ | |
$scope.alerts.push({ type: 'success', msg: "Added new location" }); | |
} | |
else | |
{ | |
$scope.alerts.push({ type: 'success', msg: "Added user" }); | |
} | |
}).error(function(data, status, header, config) { | |
if(status == 500) | |
{ | |
$scope.alerts.push({ type: 'danger', msg: "Unable to add meal type" }); | |
} | |
else if(status == 403) | |
{ | |
$scope.new_user_info = {}; | |
$scope.alerts.push({ type: 'danger', msg: "You don't have permission for this operation" }); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment