Skip to content
Permalink
Browse files

get demo and a few others

  • Loading branch information
Jeremy Mill
Jeremy Mill committed Dec 10, 2015
1 parent 1d5d09b commit 52ca1eb5c4c5edab61bfacfdd299cca6070a908d
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.SqlService;
using TeamDBAwesome.Models;
using Newtonsoft.Json;

namespace TeamDBAwesome.Controllers
{
public class GetAllTracksController : ApiController
{
public HttpResponseMessage Get()
{
MySqlService dbService = new MySqlService();

List<Track> trackList = dbService.getAllTracks();
foreach (Track track in trackList)
{
track.url = "http://a1310.phobos.apple.com/us/r1000/167/Music3/v4/00/23/38/0023383d-1616-fbe2-b3a3-7f2de268911b/mzaf_7209253486009554987.plus.aac.p.m4a";
}
string serialzed = JsonConvert.SerializeObject(trackList);

HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
message.Content = new StringContent(serialzed);

return message;

}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.SqlService;
using TeamDBAwesome.Models;
using Newtonsoft.Json;

namespace TeamDBAwesome.Controllers
{
public class GetDemographicController : ApiController
{
public HttpResponseMessage Get()
{
MySqlService dbService = new MySqlService();

List<DemoGraph> demoList = dbService.getDemos();
string serialzed = JsonConvert.SerializeObject(demoList);

HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
message.Content = new StringContent(serialzed);

return message;

}
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TeamDBAwesome.Models
{
public class DemoGraph
{
public string country { get; set; }
public int count { get; set; }
}
}
@@ -772,6 +772,73 @@ public List<Track> getOrderTracks(int orderId)
return trackList;
}

public List<DemoGraph> getDemos()
{
List<DemoGraph> demoList = new List<DemoGraph>();
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";
MySqlCommand cmd = new MySqlCommand(query, SqlConn);
MySqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
demoList.Add(new DemoGraph
{
country = GetDBString("Country", reader),
count = int.Parse(GetDBString("count", reader))
});
}
reader.Close();
}
return demoList;
}

public List<Track> getAllTracks()
{
List<Track> trackList = new List<Track>();
bool open = this.OpenConnection();
if (open == true)
{
string query = "select track.TrackId as TrackID, track.Name as trackname,track.Composer as trackcomposer, " +
"track.Milliseconds,track.Bytes, track.UnitPrice, Album.Title as albumtitle,MediaType.Name as mediatype, artist.name as artist, " +
"Genre.Name as genre " +
"from track " +
"left join ordertracks on track.TrackId = ordertracks.trackid " +
"left join Album on track.AlbumId = Album.AlbumId " +
"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 ordertracks.orderid = " + orderId;

MySqlCommand cmd = new MySqlCommand(query, SqlConn);

MySqlDataReader reader = cmd.ExecuteReader();

Track track;

while (reader.Read())
{
track = new Track();

track.TrackId = int.Parse(GetDBString("TrackId", reader));
track.TrackName = GetDBString("trackname", reader);
track.Composer = GetDBString("trackcomposer", reader);
track.Milliseconds = int.Parse(GetDBString("Milliseconds", reader));
track.Bytes = int.Parse(GetDBString("Bytes", reader));
track.UnitPrice = float.Parse(GetDBString("UnitPrice", reader));
track.AlbumTitle = GetDBString("albumtitle", reader);
track.MediaType = GetDBString("mediatype", reader);
track.Genre = GetDBString("genre", reader);
track.artist = GetDBString("artist", reader);

trackList.Add(track);
}
}

return trackList;
}

public List<int> customerOrders(int custId)
{
List<int> id_list = new List<int>();
@@ -179,11 +179,13 @@
<Compile Include="Controllers\DropPlaylistController.cs" />
<Compile Include="Controllers\GenerateInvoiceController.cs" />
<Compile Include="Controllers\GetAllInvoicesController.cs" />
<Compile Include="Controllers\GetAllTracksController.cs" />
<Compile Include="Controllers\GetCustomerController.cs" />
<Compile Include="Controllers\GetCustomerInvoiceController.cs" />
<Compile Include="Controllers\GetCustomerOrdersController.cs" />
<Compile Include="Controllers\GetCustomPlaylistController.cs" />
<Compile Include="Controllers\GetCustomPlaylistsController.cs" />
<Compile Include="Controllers\GetDemographicController.cs" />
<Compile Include="Controllers\GetEmployeeController.cs" />
<Compile Include="Controllers\GetOrderTracksController.cs" />
<Compile Include="Controllers\GetPaymentController.cs" />
@@ -204,6 +206,7 @@
<Compile Include="Models\Artist.cs" />
<Compile Include="Models\Customer.cs" />
<Compile Include="Models\CustomPlaylistId.cs" />
<Compile Include="Models\DemoGraph.cs" />
<Compile Include="Models\employee.cs" />
<Compile Include="Models\Genre.cs" />
<Compile Include="Models\Invoice.cs" />

0 comments on commit 52ca1eb

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