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 | |
| parent | 7b23b2c724bc4912158647d75fec50c4184931e6 (diff) | |
| download | project-unite-737a18b592d757449548c9b4cf179b7a1fe8e1b9.tar.gz project-unite-737a18b592d757449548c9b4cf179b7a1fe8e1b9.tar.bz2 project-unite-737a18b592d757449548c9b4cf179b7a1fe8e1b9.zip | |
Codepoints stats page
| -rw-r--r-- | Project-Unite/Controllers/StatsController.cs | 31 | ||||
| -rw-r--r-- | Project-Unite/Models/PongHighscore.cs | 2 | ||||
| -rw-r--r-- | Project-Unite/Project-Unite.csproj | 1 | ||||
| -rw-r--r-- | Project-Unite/Views/Stats/Codepoints.cshtml | 41 | ||||
| -rw-r--r-- | Project-Unite/Views/Stats/Pong.cshtml | 2 |
5 files changed, 75 insertions, 2 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 diff --git a/Project-Unite/Models/PongHighscore.cs b/Project-Unite/Models/PongHighscore.cs index 374a3b2..fb2c4d9 100644 --- a/Project-Unite/Models/PongHighscore.cs +++ b/Project-Unite/Models/PongHighscore.cs @@ -8,7 +8,7 @@ namespace Project_Unite.Models public class PongHighscore { public string UserId { get; set; } - public int CodepointsCashout { get; set; } + public long CodepointsCashout { get; set; } public int Level { get; set; } } diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index 3f73890..02325a5 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -586,6 +586,7 @@ <Content Include="Views\Bugs\ViewBug.cshtml" /> <Content Include="Views\Bugs\PostBug.cshtml" /> <Content Include="Views\Stats\Pong.cshtml" /> + <Content Include="Views\Stats\Codepoints.cshtml" /> </ItemGroup> <ItemGroup> <Folder Include="App_Data\" /> diff --git a/Project-Unite/Views/Stats/Codepoints.cshtml b/Project-Unite/Views/Stats/Codepoints.cshtml new file mode 100644 index 0000000..81b8467 --- /dev/null +++ b/Project-Unite/Views/Stats/Codepoints.cshtml @@ -0,0 +1,41 @@ +@model Project_Unite.Models.PongStatsViewModel +@{ + ViewBag.Title = "Codepoints Highscores"; +} + +<h2>Codepoints Stats</h2> + +<p>In ShiftOS, Codepoints are your primary form of currency. You earn them by doing many actions such as playing Pong, drawing pictures in Artpad, skinning and shifting in Shifter, and more.</p> + +<p>You can use them to upgrade your OS, download more apps, etc.</p> + +<p>Below is a list of all users with Codepoints, starting with the top Shifters.</p> + + +<table class="table-condensed"> + <tr> + <th>User</th> + <th>Codepoints</th> + </tr> +@foreach(var entry in Model.Highscores) +{ + <tr> + <td>@Html.UserLink(entry.UserId)</td> + <td>@entry.CodepointsCashout CP</td> + </tr> +} + </table> + +<ul class="pagination"> + @for(int i = 1; i <= Model.PageCount; i++) + { + if (i == Model.CurrentPage - 1) + { + <li class="active">@Html.ActionLink(i.ToString(), "Codepoints", "Stats", new { id = i }, null)</li> + } + else + { + <li>@Html.ActionLink(i.ToString(), "Codepoints", "Stats", new { id = i }, null)</li> + } + } +</ul>
\ No newline at end of file diff --git a/Project-Unite/Views/Stats/Pong.cshtml b/Project-Unite/Views/Stats/Pong.cshtml index faea446..e46cf4a 100644 --- a/Project-Unite/Views/Stats/Pong.cshtml +++ b/Project-Unite/Views/Stats/Pong.cshtml @@ -30,7 +30,7 @@ <ul class="pagination"> @for(int i = 1; i <= Model.PageCount; i++) { - if (i == Model.CurrentPage) + if (i == Model.CurrentPage - 1) { <li class="active">@Html.ActionLink(i.ToString(), "Pong", "Stats", new { id = i }, null)</li> } |
