summaryrefslogtreecommitdiff
path: root/Project-Unite
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-20 19:23:42 -0400
committerMichael <[email protected]>2017-05-20 19:23:42 -0400
commit92bda00b054276e09f0f80b01af91bc3fedbd5b6 (patch)
treee51d82ad623a745dde4edc80c9936cb0ba82f002 /Project-Unite
parent9b06522c668ff8d2c27367529553eab6bded2021 (diff)
downloadproject-unite-92bda00b054276e09f0f80b01af91bc3fedbd5b6.tar.gz
project-unite-92bda00b054276e09f0f80b01af91bc3fedbd5b6.tar.bz2
project-unite-92bda00b054276e09f0f80b01af91bc3fedbd5b6.zip
Contests index page
Diffstat (limited to 'Project-Unite')
-rw-r--r--Project-Unite/Controllers/ContestsController.cs19
-rw-r--r--Project-Unite/Models/ContestModels.cs70
-rw-r--r--Project-Unite/Models/IdentityModels.cs2
-rw-r--r--Project-Unite/Project-Unite.csproj3
-rw-r--r--Project-Unite/Views/Contests/Index.cshtml130
5 files changed, 224 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/ContestsController.cs b/Project-Unite/Controllers/ContestsController.cs
new file mode 100644
index 0000000..8439008
--- /dev/null
+++ b/Project-Unite/Controllers/ContestsController.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Project_Unite.Models;
+
+namespace Project_Unite.Controllers
+{
+ public class ContestsController : Controller
+ {
+ // GET: Contests
+ public ActionResult Index()
+ {
+ var model = new ApplicationDbContext().Contests.ToArray();
+ return View(model);
+ }
+ }
+} \ No newline at end of file
diff --git a/Project-Unite/Models/ContestModels.cs b/Project-Unite/Models/ContestModels.cs
new file mode 100644
index 0000000..80533c1
--- /dev/null
+++ b/Project-Unite/Models/ContestModels.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Project_Unite.Models
+{
+ public class Contest
+ {
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public DateTime StartedAt { get; set; }
+ public DateTime EndsAt { get; set; }
+ public string VideoId { get; set; }
+ public long CodepointReward1st { get; set; }
+ public long CodepointReward2nd { get; set; }
+ public long CodepointReward3rd { get; set; }
+
+
+ public bool IsEnded
+ {
+ get
+ {
+ return DateTime.Now >= EndsAt;
+ }
+ }
+
+ public ContestEntry[] Entries
+ {
+ get
+ {
+ var db = new ApplicationDbContext();
+ return db.ContestEntries.Where(x => x.ContestId == this.Id).ToArray();
+ }
+ }
+
+ }
+
+ public class ContestEntry
+ {
+ public string Id { get; set; }
+ public string AuthorId { get; set; }
+ public string ContestId { get; set; }
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public string VideoId { get; set; }
+ public string DownloadURL { get; set; }
+ public DateTime PostedAt { get; set; }
+ public bool Disqualified { get; set; }
+
+ public Like[] Downvotes
+ {
+ get
+ {
+ var db = new ApplicationDbContext();
+ return db.Likes.Where(x => x.Topic == this.Id && x.IsDislike).ToArray();
+ }
+ }
+
+ public Like[] Upvotes
+ {
+ get
+ {
+ var db = new ApplicationDbContext();
+ return db.Likes.Where(x => x.Topic == this.Id && !x.IsDislike).ToArray();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs
index 68c21fe..8959a8e 100644
--- a/Project-Unite/Models/IdentityModels.cs
+++ b/Project-Unite/Models/IdentityModels.cs
@@ -244,6 +244,8 @@ namespace Project_Unite.Models
return new ApplicationDbContext();
}
+ public DbSet<Contest> Contests { get; set; }
+ public DbSet<ContestEntry> ContestEntries { get; set; }
public DbSet<Bug> Bugs { get; set; }
public DbSet<BugTag> BugTags { get; set; }
public DbSet<BlogPost> BlogPosts { get; set; }
diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj
index 6fcf989..2d40155 100644
--- a/Project-Unite/Project-Unite.csproj
+++ b/Project-Unite/Project-Unite.csproj
@@ -623,6 +623,7 @@
<Compile Include="Controllers\APIController.cs" />
<Compile Include="Controllers\BlogController.cs" />
<Compile Include="Controllers\BugsController.cs" />
+ <Compile Include="Controllers\ContestsController.cs" />
<Compile Include="Controllers\DeveloperController.cs" />
<Compile Include="Controllers\DownloadController.cs" />
<Compile Include="Controllers\ForumController.cs" />
@@ -809,6 +810,7 @@
<Compile Include="Models\AdminViewModels.cs" />
<Compile Include="Models\BlogModels.cs" />
<Compile Include="Models\BugModels.cs" />
+ <Compile Include="Models\ContestModels.cs" />
<Compile Include="Models\Download.cs" />
<Compile Include="Models\ForumCategory.cs" />
<Compile Include="Models\ForumViewModels.cs" />
@@ -965,6 +967,7 @@
<Content Include="Views\Groups\CreateGroup.cshtml" />
<Content Include="Views\Home\AccessDenied.cshtml" />
<Content Include="Views\Home\SendFeedback.cshtml" />
+ <Content Include="Views\Contests\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
diff --git a/Project-Unite/Views/Contests/Index.cshtml b/Project-Unite/Views/Contests/Index.cshtml
new file mode 100644
index 0000000..b234340
--- /dev/null
+++ b/Project-Unite/Views/Contests/Index.cshtml
@@ -0,0 +1,130 @@
+@model IEnumerable<Project_Unite.Models.Contest>
+@{
+ ViewBag.Title = "Contests";
+ var open = Model.Where(x => x.IsEnded == false).OrderByDescending(x=>x.StartedAt);
+ var closed = Model.Where(x => x.IsEnded == true).OrderByDescending(x => x.StartedAt);
+
+}
+
+<h2>Contests</h2>
+
+<p>ShiftOS may have a team of developers behind it, but we like getting you guys, the community, involved as well. Contests are a fun and competitive way to get involved with the development of ShiftOS, whether it be through coding, art or anything else!</p>
+
+<p>Below is a list of all contests.</p>
+
+<style>
+ .text-bronze{
+ color:#cd7f32;
+ }
+ .text-silver{
+ color:#C0C0C0;
+ }
+ .text-gold{
+ color:#FFD700;
+ }
+</style>
+
+@if (Request.IsAuthenticated)
+{
+ if (User.Identity.IsDeveloper())
+ {
+<ul class="nav nav-tabs">
+ <li><a href="@Url.Action("CreateContest")"><span class="glyphicon glyphicon-plus"></span> Open a contest!</a></li>
+</ul>
+ }
+}
+
+<div class="row">
+ <div class="col-xs-4">
+ <ul data-tabs="tabs" id="tabs" class="nav nav-pills nav-stacked">
+ <li class="active"><a href="#c_open" data-tab="tab"><span class="glyphicon glyphicon-star"></span> Open [@open.Count()]</a></li>
+ <li><a href="#c_closed" data-tab="tab"><span class="glyphicon glyphicon-star-empty"></span> Closed [@closed.Count()]</a></li>
+
+ </ul>
+ </div>
+ <div class="tab-content col-xs-8">
+ <div class="tab-pane fade in active" id="c_open">
+ <h3>Open contests</h3>
+ <p>Below is a list of all open contests.</p>
+
+ <div class="row">
+ <div class="col-xs-8"><strong>Contest</strong></div>
+ <div class="col-xs-4"><strong>Actions</strong></div>
+ </div>
+ @if(open.Count() < 1)
+ {
+ <div class="row">
+ <div class="col-xs-12">
+ <p><strong><em>Sadly, no contests are open at this time. Please check back later!</em></strong></p>
+ </div>
+ </div>
+ }
+ else
+ {
+ foreach(var c in open)
+ {
+ <div class="row">
+ <div class="col-xs-8">
+ @Html.ActionLink(c.Name, "ViewContest", "Contests", new { id=c.Id}, null) <br/>
+ <p>Started at @c.StartedAt &bull; Ends at @c.EndsAt</p>
+ <p><strong>Rewards: </strong> <em class="text-gold">Gold: @c.CodepointReward1st CP</em> &bull; <em class="text-silver">Gold: @c.CodepointReward2nd CP</em> &bull; <em class="text-bronze">Bronze: @c.CodepointReward3rd CP</em></p>
+ </div>
+ <div class="col-xs-4">
+ @if (!string.IsNullOrWhiteSpace(c.VideoId))
+ {
+ <a href="http://youtube.com/[email protected]" class="btn btn-default"><span class="glyphicon glyphicon-hd-video"></span> Watch video</a>
+ }
+ @if (Request.IsAuthenticated)
+ {
+ if (User.Identity.IsDeveloper())
+ {
+ <a href="@Url.Action("CloseContest", "Contests", new { id = c.Id })" class="btn btn-danger"><span class="close"></span> End contest</a>
+ }
+ }
+ </div>
+ </div>
+
+ }
+ }
+
+ </div>
+ <div class="tab-pane fade in" id="c_closed">
+ <h3>Closed contests</h3>
+ <p>These contests have been closed and you can no longer enter to win them.</p>
+
+ <div class="row">
+ <div class="col-xs-8"><strong>Contest</strong></div>
+ <div class="col-xs-4"><strong>Actions</strong></div>
+ </div>
+ @if (closed.Count() < 1)
+ {
+ <div class="row">
+ <div class="col-xs-12">
+ <p><strong><em>No closed contests yet, maybe there's an open one?</em></strong></p>
+ </div>
+ </div>
+ }
+ else
+ {
+ foreach (var c in closed)
+ {
+ <div class="row">
+ <div class="col-xs-8">
+ @Html.ActionLink(c.Name, "ViewContest", "Contests", new { id = c.Id }, null) <br />
+ <p>Started at @c.StartedAt &bull; Ends at @c.EndsAt</p>
+ <p><strong>Rewards: </strong> <em class="text-gold">Gold: @c.CodepointReward1st CP</em> &bull; <em class="text-silver">Gold: @c.CodepointReward2nd CP</em> &bull; <em class="text-bronze">Bronze: @c.CodepointReward3rd CP</em></p>
+ </div>
+ <div class="col-xs-4">
+ @if (!string.IsNullOrWhiteSpace(c.VideoId))
+ {
+ <a href="http://youtube.com/[email protected]" class="btn btn-default"><span class="glyphicon glyphicon-hd-video"></span> Watch video</a>
+ }
+ </div>
+ </div>
+
+ }
+ }
+
+ </div>
+ </div>
+</div> \ No newline at end of file