From 737a18b592d757449548c9b4cf179b7a1fe8e1b9 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 2 May 2017 20:59:58 -0400 Subject: Codepoints stats page --- Project-Unite/Controllers/StatsController.cs | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Project-Unite/Controllers/StatsController.cs') 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(); + 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 -- cgit v1.2.3