Skip to content

Commit

Permalink
search tested and finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Mill committed Nov 18, 2015
1 parent ea23b55 commit 872242a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions TeamDBAwesome/TeamDBAwesome/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public HttpResponseMessage Get(string search="")
MatchCollection m = regex.Matches(search);
Debug.WriteLine(m);
Search dbsearch = new Search();

string searchkey = search;

if(m.Count > 0)
{
//set each one to blank first
Expand All @@ -36,15 +39,23 @@ public HttpResponseMessage Get(string search="")
dbsearch.Composer = "";
dbsearch.Genre = "";

foreach (Match match in m)
{
searchkey = searchkey.Replace(match.Value, "");
}

searchkey = searchkey.Trim();

foreach (Match match in m)
{
string tag = match.Value.Split(':')[1];
if (tag == "Media") { dbsearch.Media = search; }
else if (tag == "Album") { dbsearch.Album = search; }
else if (tag == "Artist") { dbsearch.Artist = search; }
else if (tag == "Track") { dbsearch.Track = search; }
else if (tag == "Composer") { dbsearch.Composer = search; }
else if (tag == "Genre") { dbsearch.Genre = search; }

if (tag == "Media") { dbsearch.Media = searchkey; }
else if (tag == "Album") { dbsearch.Album = searchkey; }
else if (tag == "Artist") { dbsearch.Artist = searchkey; }
else if (tag == "Track") { dbsearch.Track = searchkey; }
else if (tag == "Composer") { dbsearch.Composer = searchkey; }
else if (tag == "Genre") { dbsearch.Genre = searchkey; }
}
}
else
Expand Down

0 comments on commit 872242a

Please sign in to comment.