diff --git a/Project-Unite/Controllers/APIController.cs b/Project-Unite/Controllers/APIController.cs new file mode 100644 index 0000000..1a71209 --- /dev/null +++ b/Project-Unite/Controllers/APIController.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Newtonsoft.Json; +using Project_Unite.Models; + +namespace Project_Unite.Controllers +{ + public class APIController : Controller + { + // GET: API + public ActionResult Index() + { + return Content("Please use a valid API endpoint."); + } + + public ActionResult Releases(bool showUnstable = false, bool showObsolete = false) + { + var db = new ApplicationDbContext(); + + var releases = db.Downloads.ToArray(); + if (!showUnstable) + releases = releases.Where(x => x.IsStable == true).ToArray(); + if (!showObsolete) + releases = releases.Where(x => x.Obsolete == false).ToArray(); + + return Content(JsonConvert.SerializeObject(releases)); + } + + public ActionResult Skins() + { + var db = new ApplicationDbContext(); + return Content(JsonConvert.SerializeObject(db.Skins.ToArray())); + } + } +} \ No newline at end of file diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index 3050e2a..36b45b0 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -106,6 +106,10 @@ True + + False + Bin\Newtonsoft.Json.dll + ..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.dll True @@ -238,6 +242,7 @@ + @@ -553,6 +558,7 @@ +