summaryrefslogtreecommitdiff
path: root/Project-Unite/Controllers/StatsController.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-02 16:03:32 -0400
committerMichael <[email protected]>2017-05-02 16:03:32 -0400
commit13ad0ff4f3bce05e513768d4999a3f4ec471b872 (patch)
tree85c44b6fa88c79d3d91728dcd3aaee190aea9752 /Project-Unite/Controllers/StatsController.cs
parent73402c31a69bec303933d80a0cedaa5ae6a4f89c (diff)
downloadproject-unite-13ad0ff4f3bce05e513768d4999a3f4ec471b872.tar.gz
project-unite-13ad0ff4f3bce05e513768d4999a3f4ec471b872.tar.bz2
project-unite-13ad0ff4f3bce05e513768d4999a3f4ec471b872.zip
Pong highscore frontend.
Diffstat (limited to 'Project-Unite/Controllers/StatsController.cs')
-rw-r--r--Project-Unite/Controllers/StatsController.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/StatsController.cs b/Project-Unite/Controllers/StatsController.cs
new file mode 100644
index 0000000..71d2adc
--- /dev/null
+++ b/Project-Unite/Controllers/StatsController.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Web;
+using System.Web.Mvc;
+using Project_Unite.Models;
+
+namespace Project_Unite.Controllers
+{
+ public class StatsController : Controller
+ {
+ // GET: Stats
+ public ActionResult Pong(int id = 1)
+ {
+ 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.Pong_HighestCodepointsCashout
+ });
+ }
+
+ int pagecount = highscores.GetPageCount(10);
+ if (id > pagecount || id < 1)
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+
+ var pages = highscores.OrderByDescending(x=>x.Level).ToArray().GetItemsOnPage(id, 10);
+
+ var model = new PongStatsViewModel
+ {
+ Highscores = pages,
+ CurrentPage = id,
+ PageCount = 10
+ };
+
+ return View(model);
+ }
+ }
+} \ No newline at end of file