Skip to content
Permalink
Browse files

two more APIs

  • Loading branch information
Jeremy Mill
Jeremy Mill committed Dec 8, 2015
1 parent 9da7ec1 commit 5c6a5e07b5f7a5ed13c211d35f3462cc7d510ac2
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.SqlService;

namespace TeamDBAwesome.Controllers
{
public class AddGenreController : ApiController
{
public HttpResponseMessage Get(string GenreName)
{
HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
MySqlService sql = new MySqlService();
int newArtist = sql.AddGenre(GenreName);
message.Content = new StringContent(newArtist.ToString());
return message;
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.SqlService;

namespace TeamDBAwesome.Controllers
{
public class AddMediaTypeController : ApiController
{
public HttpResponseMessage Get(string TypeName)
{
HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
MySqlService sql = new MySqlService();
int newArtist = sql.AddMediaType(TypeName);
message.Content = new StringContent(newArtist.ToString());
return message;
}
}
}
@@ -238,6 +238,42 @@ public int AddArtist(Artist artist)
}
}

public int AddGenre(string name)
{
bool open = this.OpenConnection();
if(open == true)
{
string lastArtistQuery = "select GenreId from genre order by GenreId desc limit 1";
MySqlCommand cmd = new MySqlCommand(lastArtistQuery, SqlConn);
int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1;

string insertGenre = "insert into Genre(GenreId,Name) VALUES (" + nextNum + ",\"" + name + "\")";
return nextNum;
}
else
{
return 0;
}
}

public int AddMediaType(string name)
{
bool open = this.OpenConnection();
if (open == true)
{
string lastArtistQuery = "select MediaTypeId from MediaType order by MediaTypeId desc limit 1";
MySqlCommand cmd = new MySqlCommand(lastArtistQuery, SqlConn);
int nextNum = int.Parse(cmd.ExecuteScalar() + "") + 1;

string insertGenre = "insert into MediaType(MediaTypeId,Name) VALUES (" + nextNum + ",\"" + name + "\")";
return nextNum;
}
else
{
return 0;
}
}

public int addAlbum(Album album)
{
bool open = this.OpenConnection();
@@ -166,6 +166,8 @@
<Compile Include="Controllers\AddAlbumController.cs" />
<Compile Include="Controllers\AddArtistController.cs" />
<Compile Include="Controllers\AddCustomPlaylistController.cs" />
<Compile Include="Controllers\AddGenreController.cs" />
<Compile Include="Controllers\AddMediaTypeController.cs" />
<Compile Include="Controllers\AddPaymentController.cs" />
<Compile Include="Controllers\AddPlaylistController.cs" />
<Compile Include="Controllers\AddTrackController.cs" />

0 comments on commit 5c6a5e0

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