Skip to content

Instantly share code, notes, and snippets.

Created April 20, 2014 16:26
Show Gist options
  • Save anonymous/11118231 to your computer and use it in GitHub Desktop.
Save anonymous/11118231 to your computer and use it in GitHub Desktop.
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