Skip to content
Permalink
Browse files

Customer info and User playlist

  • Loading branch information
sec11008 committed Dec 10, 2015
1 parent 52ca1eb commit f909655bb497ffe51422de611d7962e43f7a1723
@@ -16,7 +16,7 @@ public HttpResponseMessage Get()
{
MySqlService dbService = new MySqlService();

List<DemoGraph> demoList = dbService.getDemos();
List<Customer> demoList = dbService.getDemos();
string serialzed = JsonConvert.SerializeObject(demoList);

HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
@@ -772,23 +772,37 @@ public List<Track> getOrderTracks(int orderId)
return trackList;
}

public List<DemoGraph> getDemos()
public List<Customer> getDemos()
{
List<DemoGraph> demoList = new List<DemoGraph>();
List<Customer> demoList = new List<Customer>();
bool open = this.OpenConnection();
if(open == true)
{
string query = "select country,count(*) from customer left join person on customer.PersonId = person.PersonId group by Country";
string query = "select * from customer left join person on customer.PersonId = person.PersonId";
MySqlCommand cmd = new MySqlCommand(query, SqlConn);
MySqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
while (reader.Read())
{
demoList.Add(new DemoGraph
{
country = GetDBString("Country", reader),
count = int.Parse(GetDBString("count", reader))
demoList.Add(new Customer {
FName = GetDBString("FirstName", reader),
LName = GetDBString("LastName", reader),
CustomerID = int.Parse(GetDBString("CustomerID", reader)),
Address = GetDBString("Address", reader),
City = GetDBString("City", reader),
State = GetDBString("State", reader),
Post = GetDBString("PostalCode", reader),
Country = GetDBString("Country", reader),
Phone = GetDBString("Phone", reader),
Fax = GetDBString("Fax", reader),
Email = GetDBString("Email", reader),
Company = GetDBString("Company", reader),
SupportRepId = int.Parse(GetDBString("SupportRepId", reader)),
PersonID = int.Parse(GetDBString("PersonID", reader)),
});
}



reader.Close();
}
return demoList;
@@ -1407,7 +1421,7 @@ public List<Track> GetCustomPlayListTracks(int PlaylistID)
"left join mediatype on track.MediaTypeId=mediatype.MediaTypeId " +
"left join genre on track.GenreId = genre.GenreId " +
"left join artist on album.artistid = artist.artistid " +
"where playlist.PlaylistId = " + PlaylistID;
"where myplaylist.PlaylistId = " + PlaylistID;

MySqlCommand cmd = new MySqlCommand(query, SqlConn);

@@ -184,8 +184,8 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$scope.custInfoGridOptions = {
enableFiltering: true,
columnDefs: [
{field: 'Fname', displayName: 'First Name'},
{field: 'Lname', displayName: 'Last Name'},
{field: 'FName', displayName: 'First Name'},
{field: 'LName', displayName: 'Last Name'},
{field: 'Address'},
{field: 'City'},
{field: 'State'},
@@ -196,7 +196,36 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
{field: 'Email'},
{field: 'Company'}
]
}

$scope.custInfoGridOptions.data = [
{ FName: "TEST" ,
LName: "TEST" ,
Address: "TEST" ,
City: "TEST" ,
State: "TEST" ,
Post: "TEST" ,
Country: "TEST" ,
Phone: "TEST" ,
Fax : "TEST" ,
Email: "TEST" ,
Company: "TEST"
}

]

$scope.getDemographics = function () {
$scope.custInfoGridOptions.data = [];
console.log($scope.custInfoGridOptions.data);
$http.get("http://localhost:50031/api/GetDemographic")
.success(function (response) {
$scope.custInfoGridOptions.data = angular.copy(response);
$scope.custInfoGridOptions.data.splice(0, 1);
console.log(response);
})
}



//End Customer Demographics

@@ -205,6 +234,15 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$scope.currentPlaylist = 0;
$scope.addingTrack = false;

$scope.playlistGridOptions = {
columnDefs: [
{ field: 'PlaylistID', displayName: 'Playlist Id'},
{ field: 'Name', displayName: 'Playlist Name' },
{ field: 'Edit', cellTemplate: '<center><button ng-click="grid.addScope.debug();">Edit</button></center>' },
{ field: 'Delete', cellTemplate: '<center><button ng-click="grid.addScope.deletePlaylist(row.entity.PlaylistID);">Delete</button></center>' }
]
}

$scope.addPlaylist = function () {
var name = prompt("Enter the name of the playlist");
if (name != null) {
@@ -213,11 +251,12 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
console.log(response);
})
}
$scope.getPlaylists();
$state.reload();
window.setTimeout($scope.getPlaylists(),1000);

}

$scope.toEdit = function (playlistID) {
alert("edit");
$scope.editing = true;
$scope.currentPlaylist = playlistID;
$scope.getPlaylistTracks(playlistID);
@@ -228,16 +267,18 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/GetPlaylistList")
.success(function (response) {
$scope.playlists = angular.copy(response);
$scope.playlistGridOptions.data = angular.copy(response);
console.log(response);
})
}

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

}

$scope.dropPlaylist = function (playlistID) {
@@ -263,13 +304,15 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
.success(function (response) {
console.log(response);
})
$scope.getPlaylistTracks($scope.currentPlaylist);
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist),1000);
}

$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);
}
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);

}
$scope.dropTrack = function (trackID)
{
@@ -325,6 +368,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
//Reports
$scope.inventoryGridOptions = {
enableFiltering: true,
showColumnFooter: true,
columnDefs: [
{ field: 'Title', displayName: 'Track Title' },
{ field: 'Artist' },
@@ -355,4 +399,8 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt

//End Reports

$scope.debug = function () {
alert("alert")
}

});
@@ -408,4 +408,152 @@ angular.module('routerApp').controller('userController', function ($q, $window,

/* Begin Logic */

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

$scope.playlistGridOptions = {
columnDefs: [
{ field: 'PlaylistID', displayName: 'Playlist Id' },
{ field: 'Name', displayName: 'Playlist Name' },
{ field: 'Edit', cellTemplate: '<center><button ng-click="grid.addScope.debug();">Edit</button></center>' },
{ field: 'Delete', cellTemplate: '<center><button ng-click="grid.addScope.deletePlaylist(row.entity.PlaylistID);">Delete</button></center>' }
]
}

$scope.addCustomPlaylist = function () {
var sub = HolderService.getBlankCustomPlaylist();
sub.CustomerId = $cookies.get('userid');
sub.Name = prompt("Enter the name of the playlist");
if (name != null) {
var promise = $http({
method: "post",
url: "http://localhost:50031/api/AddCustomPlaylist",
headers: {
contentType: "application/json"
},
data: sub
}).
success(function (data, status, headers, config) {
$scope.messages = 'You created a playlist!';
alert($scope.messages);
}).
error(function (error, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.';
alert($scope.messages);
});
}
window.setTimeout($scope.getCustomPlaylists(), 1000);

}

$scope.toEdit = function (playlistID) {
$scope.editing = true;
$scope.currentPlaylist = playlistID;
$scope.getCustomPlaylistTracks(playlistID);
alert($scope.currentPlaylist + "");
}

$scope.getCustomPlaylists = function () {
$scope.playlists = [];
$http.get("http://localhost:50031/api/GetCustomPlaylists?CustomerID=" + $cookies.get('userid'))
.success(function (response) {
$scope.playlists = angular.copy(response);
$scope.playlistGridOptions.data = angular.copy(response);
console.log(response);
})
}

$scope.deletePlaylist = function (playlistID) {
if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) {
$scope.dropCustomPlaylist(playlistID);
}
window.setTimeout($scope.getCustomPlaylists(), 1000);

}

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

$scope.getCustomPlaylistTracks = function (playlistID) {
$scope.playlistTracks = [];
console.log(playlistID);
$http.get("http://localhost:50031/api/GetCustomPlaylist?PlaylistID=" + playlistID)
.success(function (response) {
$scope.playlistTracks = angular.copy(response);
console.log(response);
})

}

$scope.addToCustomPlaylist = function (trackID) {
console.log(trackID);
$http.get("http://localhost:50031/api/AddTrackCustomPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) {
console.log(response);
})
window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000);
}

$scope.deleteTrack = function (trackID) {
if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) {
$scope.dropCustomTrack(trackID);
}
window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000);

}
$scope.dropCustomTrack = function (trackID) {
$http.get("http://localhost:50031/api/RemoveCustomTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) {
console.log(response);
})
}


$scope.trackSearchGridOptions = {
enableSorting: true,
columnDefs: [
{ field: 'TrackId', displayName: ' ', width: "5%", cellTemplate: '<center><button ng-click="grid.appScope.addToCustomPlaylist(row.entity.TrackId);" class="btn btn-success btn-xs"> + </button></center>' },
{ field: 'TrackName', displayName: ' Track Name', width: "20%" },
{ field: 'artist', displayName: ' Artist Name', width: "20%" },
{ field: 'AlbumTitle', displayName: ' Album ', width: "15%" },
{ field: 'MediaType', displayName: ' Media ', width: "10%" },
{ field: 'Genre', displayName: ' Genre ', width: "10%" },
{ field: 'Clip', displayName: ' Clip ', width: "10%" },
{ field: 'UnitPrice', displayName: ' Price ', width: "10%" }
]
};

$scope.trackSearch = function (token, category) {
console.log(token);
console.log(category);
console.log($scope.data);
$http.get("http://localhost:50031/api/Search?search=" + token)
.success(function (response) {
$scope.data = angular.copy(response);
console.log(response);
if (category == "Track") {
$scope.trackSearchGridOptions.data = $scope.data.Track;
}
else if (category == "Artist") {
$scope.trackSearchGridOptions.data = $scope.data.Artist;
}
else if (category == "Composer") {
$scope.trackSearchGridOptions.data = $scope.data.Composer;
}
else if (category == "Genre") {
$scope.trackSearchGridOptions.data = $scope.data.Genre;
}
else if (category == "Media") {
$scope.trackSearchGridOptions.data = $scope.data.Media;
}
});
}

//End Playlist Editor
});
@@ -2,7 +2,7 @@
<div ng-controller="adminController">

<h2 class=''>Customer Info</h2>
<div>
<div ng-init="getDemographics();">

<!-- <div id="messages" class="alert alert-info" data-ng-show="messages" data-ng-bind="messages"></div>
Generate a current list of questions w/ toggle disable
@@ -4,9 +4,10 @@
</head>
<div ng-controller="adminController">
<!--List of playlists-->
<div ng-hide="editing" ng-init="getPlaylists();">
<div ng-hide="editing" ng-init="getPlaylists();" style="height: 50%">
<a ng-click="addPlaylist();">Create New Playlist</a>
<table>
<!--<div id="playlistGrid" ui-grid="playlistGridOptions" class="gridStyle" ng-if="!editing" style="height: 400px"></div>-->
<table>
<tr>
<td>Playlist Id</td>
<td>Playlist Name</td>
@@ -18,5 +18,5 @@ <h1 class=''>Results View here</h1>
milliseconds, bytes, and/or composer. These can be summary reports by artist name, by
compose, genre, etc. The report needs to work for all combinations. This is utilizing the
media dimension-->
<div id="inventory" ui-grid="inventoryGridOptions" class="grid"></div>
<div id="inventory" ui-grid="inventoryGridOptions" class="grid" ng-if=""></div>
</div>

0 comments on commit f909655

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