Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Customer info and User playlist
  • Loading branch information
sec11008 committed Dec 10, 2015
1 parent 52ca1eb commit f909655
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 24 deletions.
Expand Up @@ -16,7 +16,7 @@ namespace TeamDBAwesome.Controllers
{
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);
Expand Down
32 changes: 23 additions & 9 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Expand Up @@ -772,23 +772,37 @@ namespace TeamDBAwesome.SqlService
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;
Expand Down Expand Up @@ -1407,7 +1421,7 @@ namespace TeamDBAwesome.SqlService
"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);

Expand Down
62 changes: 55 additions & 7 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
Expand Up @@ -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'},
Expand All @@ -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

Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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)
{
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -355,4 +399,8 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt

//End Reports

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

});
148 changes: 148 additions & 0 deletions TeamDBAwesome/TeamDBAwesome/js/userController.js
Expand Up @@ -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 changes: 1 addition & 1 deletion TeamDBAwesome/TeamDBAwesome/pages/admin-customerinfo.html
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions TeamDBAwesome/TeamDBAwesome/pages/admin-playlist-manager.html
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion TeamDBAwesome/TeamDBAwesome/pages/admin-view.html
Expand Up @@ -18,5 +18,5 @@
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.