diff options
Diffstat (limited to 'Project-Unite/Controllers/StatsController.cs')
| -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 |
