Skip to content
Permalink
Browse files

Add and delete playlist are working

There is a bug where the list doesn't update until the page is reloaded
most of the time
  • Loading branch information
sec11008 committed Dec 8, 2015
1 parent b0d9c00 commit 85976a1a5f90d8581361ff5c6bfda57d7749be2c
@@ -16,13 +16,14 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt

/* BEGIN LOGIC */

//New Media
$scope.showMediaOptions = true;
$scope.showTrackFields = false;
$scope.showAlbumFields = false;
$scope.showArtistFields = false;
$scope.showGenreFields = false;
$scope.showMediaTypeFields = false;
$scope.editing = false;



$scope.back = function () {
@@ -49,7 +50,9 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$scope.toCreateMediaType = function () {
$scope.showMediaOptions = false;
};
//End New Media

//CustomerDemographics
$scope.gridOptions = {
enableFiltering: true,
columnDefs: [
@@ -83,9 +86,26 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt

}
]
//End Customer Demographics

//Playlist Editor
$scope.editing = false;
$scope.currentPlaylist = 0;

$scope.addPlaylist = function () {
var name = prompt("Enter the name of the playlist");
if (name != null) {
$http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name)
.success(function (response) {
console.log(response);
})
}
$scope.getPlaylists();
}

$scope.toEdit = function (playlistID) {
$scope.editing = true;
$scope.currentPlaylist = playlistID;
$scope.getPlaylistTracks(playlistID);
}

@@ -97,6 +117,21 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
console.log(response);
})
}

$scope.deletePlaylist = function (playlistID) {
if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) {
$scope.dropPlaylist(playlistID);
}
$scope.getPlaylists();
}

$scope.dropPlaylist = function (playlistID) {
$http.get("http://localhost:50031/api/DropPlaylist?PlaylistID="+ playlistID)
.success(function (response) {
console.log(response);
})
}

$scope.getPlaylistTracks = function (playlistID) {
$scope.playlistTracks = [];
$http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID)
@@ -105,5 +140,13 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
console.log(response);
})

}
}

$scope.deleteTrack = function (trackID) {
if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) {
$scope.dropTrack(trackID);
}
}

//End Playlist Editor
});
@@ -4,7 +4,7 @@
</head>
<div ng-controller="adminController">
<div ng-hide="editing" ng-init="getPlaylists();">
<a>Create New Playlist</a>
<a ng-click="addPlaylist();">Create New Playlist</a>
<table>
<tr>
<td>Playlist Id</td>
@@ -16,7 +16,7 @@
<td>{{ playlist.PlaylistID }}</td>
<td>{{ playlist.Name }}</td>
<td><a ng-click="toEdit(playlist.PlaylistID);">Edit</a></td>
<td><a ui-sref="admin-delete-playlist">Delete</a></td>
<td><a ng-click="deletePlaylist(playlist.PlaylistID)">Delete</a></td>
</tr>
</table>
</div>
@@ -37,7 +37,7 @@
<td>{{ track.artist }}</td>
<td>{{ track.Milliseconds }}</td>
<td>{{ track.UnitPrice | currency }}</td>
<td><a ui-sref="admin-delete-playlist">Delete</a></td>
<td><a ng-click="deleteTrack(track.TrackId)">Delete</a></td>
</tr>
</table>
</div>

0 comments on commit 85976a1

Please sign in to comment.
You can’t perform that action at this time.