diff options
| author | Michael <[email protected]> | 2017-04-07 12:50:25 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-07 12:50:25 -0400 |
| commit | 4e0948aa1925916edeaa1c2fce041af8c1b5ad8c (patch) | |
| tree | 6980f8dfc71f5c74a0e0aad9a1ebbeb6b9bdf705 /Project-Unite/Controllers | |
| parent | eca15c91f8c4d09c036bf13202bd78a7b31bde1b (diff) | |
| download | project-unite-4e0948aa1925916edeaa1c2fce041af8c1b5ad8c.tar.gz project-unite-4e0948aa1925916edeaa1c2fce041af8c1b5ad8c.tar.bz2 project-unite-4e0948aa1925916edeaa1c2fce041af8c1b5ad8c.zip | |
Begin work on Unite API.
Diffstat (limited to 'Project-Unite/Controllers')
| -rw-r--r-- | Project-Unite/Controllers/APIController.cs | 38 |
1 files changed, 38 insertions, 0 deletions
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 |
