Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed add album and add track
  • Loading branch information
sec11008 committed Dec 9, 2015
1 parent 84518cd commit 5a7d284
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
10 changes: 5 additions & 5 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Expand Up @@ -151,8 +151,8 @@ namespace TeamDBAwesome.SqlService
MySqlCommand cmd = new MySqlCommand(lastTackQuery, SqlConn); MySqlCommand cmd = new MySqlCommand(lastTackQuery, SqlConn);
int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1; int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1;


string albumAndArtistQuery = "select AlbumId,ArtistID from album left join artist on album.artistid = artist.artistid " + string albumAndArtistQuery = "select AlbumId, artist.ArtistID from album left join artist on album.artistid = artist.artistid " +
"where Title = " + track.AlbumTitle + " and Name = " + track.artist; "where Title = '" + track.AlbumTitle + "' and Name = '" + track.artist+ "'";
cmd = new MySqlCommand(albumAndArtistQuery, SqlConn); cmd = new MySqlCommand(albumAndArtistQuery, SqlConn);
MySqlDataReader reader = cmd.ExecuteReader(); MySqlDataReader reader = cmd.ExecuteReader();
string albumidstring = "", artistidstring = ""; string albumidstring = "", artistidstring = "";
Expand All @@ -173,7 +173,7 @@ namespace TeamDBAwesome.SqlService
reader.Close(); reader.Close();


int mediatypeid = 0; int mediatypeid = 0;
string mediatypeQuery = "select MediaTypeId from mediatype where Name = " + track.MediaType; string mediatypeQuery = "select MediaTypeId from mediatype where Name = '" + track.MediaType +"'";
cmd = new MySqlCommand(mediatypeQuery, SqlConn); cmd = new MySqlCommand(mediatypeQuery, SqlConn);
string mediaTypeIdString = cmd.ExecuteScalar() + ""; string mediaTypeIdString = cmd.ExecuteScalar() + "";
if(String.IsNullOrEmpty(mediaTypeIdString)) if(String.IsNullOrEmpty(mediaTypeIdString))
Expand All @@ -186,7 +186,7 @@ namespace TeamDBAwesome.SqlService
} }


int genreId=0; int genreId=0;
string genreIdQuery = "select mediatypeid from mediatype where Name = " + track.MediaType; string genreIdQuery = "select mediatypeid from mediatype where Name = '" + track.MediaType +"'";
cmd = new MySqlCommand(genreIdQuery, SqlConn); cmd = new MySqlCommand(genreIdQuery, SqlConn);
string genreIdString = cmd.ExecuteScalar() + ""; string genreIdString = cmd.ExecuteScalar() + "";
if (String.IsNullOrEmpty(genreIdString)) if (String.IsNullOrEmpty(genreIdString))
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace TeamDBAwesome.SqlService
int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1; int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1;


int artistId = 0; int artistId = 0;
string getArtistIdQuery = "select ArtistId from artist where name = " + album.Artist; string getArtistIdQuery = "select ArtistId from artist where name = '" + album.Artist +"'";
cmd = new MySqlCommand(getArtistIdQuery, SqlConn); cmd = new MySqlCommand(getArtistIdQuery, SqlConn);
string idString = cmd.ExecuteScalar() + ""; string idString = cmd.ExecuteScalar() + "";
if(String.IsNullOrEmpty(idString)) { return 0; } if(String.IsNullOrEmpty(idString)) { return 0; }
Expand Down
19 changes: 10 additions & 9 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
@@ -1,6 +1,6 @@
// This controller will hold logic for the employee Portal homepage (Order List, Logout), Customer Info, Media Center, and Reports // This controller will hold logic for the employee Portal homepage (Order List, Logout), Customer Info, Media Center, and Reports


angular.module('routerApp').controller('adminController', function ($scope, $http, $log, $timeout, $cookies, urlService, $anchorScroll, $location, $q, $state, $rootScope) { angular.module('routerApp').controller('adminController', function ($scope, $http, $log, $timeout, $cookies, urlService, $anchorScroll, $location, $q, $state, $rootScope, HolderService) {
/* Retrieve Url */ /* Retrieve Url */
var url = urlService.web; var url = urlService.web;
$cookies.put('PAGE', 'Admin'); $cookies.put('PAGE', 'Admin');
Expand Down Expand Up @@ -71,9 +71,9 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
sub.MediaType = newTrack.mediaType; sub.MediaType = newTrack.mediaType;
sub.Genre = newTrack.genre; sub.Genre = newTrack.genre;
sub.Composer = newTrack.composer; sub.Composer = newTrack.composer;
sub.Milliseconds = newTrack.milliseconds; sub.Milliseconds = parseInt(newTrack.milliseconds);
sub.Bytes = newTrack.bytes; sub.Bytes = parseInt(newTrack.bytes);
sub.UnitPrice = newTrack.unitPrice; sub.UnitPrice = parseFloat(newTrack.unitPrice);
console.log(sub); console.log(sub);


var promise = $http({ var promise = $http({
Expand All @@ -86,12 +86,15 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
}). }).
success(function (data, status, headers, config) { success(function (data, status, headers, config) {
$scope.messages = 'You created a track!'; $scope.messages = 'You created a track!';
console.log(response);
alert($scope.messages); alert($scope.messages);
}). }).
error(function (error, status, headers, config) { error(function (error, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.'; $scope.messages = 'There was a network error. Try again later.';
alert($scope.messages); alert($scope.messages);
console.log(error);
console.log(error.ExceptionMessage);
console.log(error.ExeceptionType);
console.log(error.StackTrace);
}); });
} }


Expand All @@ -113,7 +116,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
}). }).
success(function (data, status, headers, config) { success(function (data, status, headers, config) {
$scope.messages = 'You created an artist!'; $scope.messages = 'You created an artist!';
console.log(response);
alert($scope.messages); alert($scope.messages);
}). }).
error(function (error, status, headers, config) { error(function (error, status, headers, config) {
Expand All @@ -140,12 +142,11 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
}, },
data: sub data: sub
}). }).
success(function (data, status, headers, config) { success(function (data, status, headers, config, response) {
$scope.messages = 'You created an album!'; $scope.messages = 'You created an album!';
console.log(response);
alert($scope.messages); alert($scope.messages);
}). }).
error(function (error, status, headers, config) { error(function (error, status, headers, config, response) {
$scope.messages = 'There was a network error. Try again later.'; $scope.messages = 'There was a network error. Try again later.';
alert($scope.messages); alert($scope.messages);
console.log(error); console.log(error);
Expand Down

0 comments on commit 5a7d284

Please sign in to comment.