diff options
| author | Michael <[email protected]> | 2017-05-02 20:59:58 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-02 20:59:58 -0400 |
| commit | 737a18b592d757449548c9b4cf179b7a1fe8e1b9 (patch) | |
| tree | ab2754368a5b88ff7bdc00236396d829bda7b657 /Project-Unite/Controllers | |
| parent | 7b23b2c724bc4912158647d75fec50c4184931e6 (diff) | |
| download | project-unite-737a18b592d757449548c9b4cf179b7a1fe8e1b9.tar.gz project-unite-737a18b592d757449548c9b4cf179b7a1fe8e1b9.tar.bz2 project-unite-737a18b592d757449548c9b4cf179b7a1fe8e1b9.zip | |
Codepoints stats page
Diffstat (limited to 'Project-Unite/Controllers')
| -rw-r--r-- | Project-Unite/Controllers/StatsController.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/StatsController.cs b/Project-Unite/Controllers/StatsController.cs index fbfaf17..cce3da3 100644 --- a/Project-Unite/Controllers/StatsController.cs +++ b/Project-Unite/Controllers/StatsController.cs @@ -42,5 +42,36 @@ namespace Project_Unite.Controllers return View(model); } + + public ActionResult Codepoints(int id) + { + var db = new ApplicationDbContext(); + var highscores = new List<PongHighscore>(); + foreach (var user in db.Users) + { + highscores.Add(new PongHighscore + { + UserId = user.Id, + Level = user.Pong_HighestLevel, + CodepointsCashout = user.Codepoints + }); + } + + id = id - 1; + + int pagecount = highscores.GetPageCount(10); + if (id > pagecount || id < 0) + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + + var pages = highscores.OrderByDescending(x => x.CodepointsCashout).ToArray().GetItemsOnPage(id, 10); + + var model = new PongStatsViewModel + { + Highscores = pages.ToList(), + CurrentPage = id, + PageCount = 10 + }; + return View(model); + } } }
\ No newline at end of file |
