Skip to content
Permalink
Browse files

Fixed add album and add track

  • Loading branch information
sec11008 committed Dec 9, 2015
1 parent 84518cd commit 5a7d284193f7adfdedd12c31045df98406dc120f
@@ -151,8 +151,8 @@ public int AddTrack(Track track)
MySqlCommand cmd = new MySqlCommand(lastTackQuery, SqlConn);
int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1;

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

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);
string mediaTypeIdString = cmd.ExecuteScalar() + "";
if(String.IsNullOrEmpty(mediaTypeIdString))
@@ -186,7 +186,7 @@ public int AddTrack(Track track)
}

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);
string genreIdString = cmd.ExecuteScalar() + "";
if (String.IsNullOrEmpty(genreIdString))
@@ -290,7 +290,7 @@ public int addAlbum(Album album)
int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1;

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);
string idString = cmd.ExecuteScalar() + "";
if(String.IsNullOrEmpty(idString)) { return 0; }
@@ -1,6 +1,6 @@
// 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 */
var url = urlService.web;
$cookies.put('PAGE', 'Admin');
@@ -71,9 +71,9 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
sub.MediaType = newTrack.mediaType;
sub.Genre = newTrack.genre;
sub.Composer = newTrack.composer;
sub.Milliseconds = newTrack.milliseconds;
sub.Bytes = newTrack.bytes;
sub.UnitPrice = newTrack.unitPrice;
sub.Milliseconds = parseInt(newTrack.milliseconds);
sub.Bytes = parseInt(newTrack.bytes);
sub.UnitPrice = parseFloat(newTrack.unitPrice);
console.log(sub);

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

@@ -113,7 +116,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
}).
success(function (data, status, headers, config) {
$scope.messages = 'You created an artist!';
console.log(response);
alert($scope.messages);
}).
error(function (error, status, headers, config) {
@@ -140,12 +142,11 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
},
data: sub
}).
success(function (data, status, headers, config) {
success(function (data, status, headers, config, response) {
$scope.messages = 'You created an album!';
console.log(response);
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.';
alert($scope.messages);
console.log(error);

0 comments on commit 5a7d284

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