diff options
| author | Michael <[email protected]> | 2017-05-02 16:06:40 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-02 16:06:40 -0400 |
| commit | 733d9992d504715b11314e405a012dca771ee129 (patch) | |
| tree | ab1a1872f88211c6180aedd7f24386161bfa97da /Project-Unite | |
| parent | 13ad0ff4f3bce05e513768d4999a3f4ec471b872 (diff) | |
| download | project-unite-733d9992d504715b11314e405a012dca771ee129.tar.gz project-unite-733d9992d504715b11314e405a012dca771ee129.tar.bz2 project-unite-733d9992d504715b11314e405a012dca771ee129.zip | |
pong highscore API
Diffstat (limited to 'Project-Unite')
| -rw-r--r-- | Project-Unite/Controllers/APIController.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/APIController.cs b/Project-Unite/Controllers/APIController.cs index 9d22a75..b9cdcbe 100644 --- a/Project-Unite/Controllers/APIController.cs +++ b/Project-Unite/Controllers/APIController.cs @@ -12,6 +12,81 @@ namespace Project_Unite.Controllers { public class APIController : Controller { + public ActionResult GetPongCP() + { + try + { + string token = Request.Headers["Authentication"].Remove(0, 6); + var user = ACL.GetUserFromToken(token); + if (user == null) + return new HttpStatusCodeResult(HttpStatusCode.Forbidden); + return Content(user.Pong_HighestCodepointsCashout.ToString()); + } + catch + { + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + } + } + + public ActionResult SetPongCP(int id) + { + try + { + string token = Request.Headers["Authentication"].Remove(0, 6); + + var db = new ApplicationDbContext(); + var t = db.OAuthTokens.FirstOrDefault(x => x.Id == token); + var user = db.Users.FirstOrDefault(x => x.Id == t.UserId); + user.Pong_HighestCodepointsCashout = id; + db.SaveChanges(); + return new HttpStatusCodeResult(200); + } + catch + { + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + } + } + + + public ActionResult GetPongLevel() + { + try + { + string token = Request.Headers["Authentication"].Remove(0, 6); + var user = ACL.GetUserFromToken(token); + if (user == null) + return new HttpStatusCodeResult(HttpStatusCode.Forbidden); + return Content(user.Pong_HighestLevel.ToString()); + } + catch + { + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + } + } + + public ActionResult SetPongLevel(int id) + { + try + { + string token = Request.Headers["Authentication"].Remove(0, 6); + + var db = new ApplicationDbContext(); + var t = db.OAuthTokens.FirstOrDefault(x => x.Id == token); + var user = db.Users.FirstOrDefault(x => x.Id == t.UserId); + + user.Pong_HighestLevel = id; + db.SaveChanges(); + return new HttpStatusCodeResult(200); + } + catch + { + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + } + } + + + + public ActionResult GetCodepoints() { try |
