From f909655bb497ffe51422de611d7962e43f7a1723 Mon Sep 17 00:00:00 2001 From: Sebastian Colorado Date: Thu, 10 Dec 2015 02:11:04 -0500 Subject: [PATCH] Customer info and User playlist --- .../Controllers/GetDemographicController.cs | 2 +- .../TeamDBAwesome/SqlService/MySqlService.cs | 32 ++-- .../TeamDBAwesome/js/adminController.js | 62 +++++++- .../TeamDBAwesome/js/userController.js | 148 ++++++++++++++++++ .../pages/admin-customerinfo.html | 2 +- .../pages/admin-playlist-manager.html | 5 +- .../TeamDBAwesome/pages/admin-view.html | 2 +- .../TeamDBAwesome/pages/user-playlists.html | 82 +++++++++- 8 files changed, 311 insertions(+), 24 deletions(-) diff --git a/TeamDBAwesome/TeamDBAwesome/Controllers/GetDemographicController.cs b/TeamDBAwesome/TeamDBAwesome/Controllers/GetDemographicController.cs index 56837fb..58ea57d 100644 --- a/TeamDBAwesome/TeamDBAwesome/Controllers/GetDemographicController.cs +++ b/TeamDBAwesome/TeamDBAwesome/Controllers/GetDemographicController.cs @@ -16,7 +16,7 @@ namespace TeamDBAwesome.Controllers { MySqlService dbService = new MySqlService(); - List demoList = dbService.getDemos(); + List demoList = dbService.getDemos(); string serialzed = JsonConvert.SerializeObject(demoList); HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK); diff --git a/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs b/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs index 202cc94..3ba7142 100644 --- a/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs +++ b/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs @@ -772,23 +772,37 @@ namespace TeamDBAwesome.SqlService return trackList; } - public List getDemos() + public List getDemos() { - List demoList = new List(); + List demoList = new List(); 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 @@ 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); diff --git a/TeamDBAwesome/TeamDBAwesome/js/adminController.js b/TeamDBAwesome/TeamDBAwesome/js/adminController.js index c443763..71d48cb 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/adminController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/adminController.js @@ -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: '
' }, + { field: 'Delete', cellTemplate: '
' } + ] + } + $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") + } + }); \ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/js/userController.js b/TeamDBAwesome/TeamDBAwesome/js/userController.js index 7ec8814..9395e57 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/userController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/userController.js @@ -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: '
' }, + { field: 'Delete', cellTemplate: '
' } + ] + } + + $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: '
' }, + { 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 }); diff --git a/TeamDBAwesome/TeamDBAwesome/pages/admin-customerinfo.html b/TeamDBAwesome/TeamDBAwesome/pages/admin-customerinfo.html index 4b747d1..00b87f8 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/admin-customerinfo.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/admin-customerinfo.html @@ -2,7 +2,7 @@

Customer Info

-
+
-
+
Create New Playlist - + +
diff --git a/TeamDBAwesome/TeamDBAwesome/pages/admin-view.html b/TeamDBAwesome/TeamDBAwesome/pages/admin-view.html index a394124..5f1694c 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/admin-view.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/admin-view.html @@ -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--> -
+
\ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/pages/user-playlists.html b/TeamDBAwesome/TeamDBAwesome/pages/user-playlists.html index c7a6aa9..bff9521 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/user-playlists.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/user-playlists.html @@ -1,5 +1,5 @@
-

Playlist Stuff goes here


+ + + +
Playlist Id Playlist Name
+ + + + + + + + + + + + +
Playlist IdPlaylist Name
{{ playlist.PlaylistID }}{{ playlist.Name }}EditDelete
+
+ +
+ Back + Add a track + +
+
+ + + + +
+
+
+
+
+
+ +
+
+
+
+ Done +
+
+
+ + + + + + + + + + + + + + + + + + +
Track IdTrack NameArtistLengthPrice
{{ track.TrackId }}{{ track.TrackName }}{{ track.artist }}{{ track.Milliseconds | formatTime }}{{ track.UnitPrice | currency }}Delete
+
+
\ No newline at end of file