summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-20 19:42:32 -0400
committerMichael <[email protected]>2017-05-20 19:42:32 -0400
commitb0c200196e5506b456895f9ee0c4c8dcd547fdb7 (patch)
tree05e04d50c950ca0dfedbc5058a0c9d928162f241
parent12a8540d72c7a3c84264e36b5a92b71c3bd1659a (diff)
downloadproject-unite-b0c200196e5506b456895f9ee0c4c8dcd547fdb7.tar.gz
project-unite-b0c200196e5506b456895f9ee0c4c8dcd547fdb7.tar.bz2
project-unite-b0c200196e5506b456895f9ee0c4c8dcd547fdb7.zip
viewcontest page
-rw-r--r--Project-Unite/Controllers/ContestsController.cs11
-rw-r--r--Project-Unite/Project-Unite.csproj1
-rw-r--r--Project-Unite/Views/Contests/ViewContest.cshtml94
3 files changed, 106 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/ContestsController.cs b/Project-Unite/Controllers/ContestsController.cs
index 8439008..4b41f91 100644
--- a/Project-Unite/Controllers/ContestsController.cs
+++ b/Project-Unite/Controllers/ContestsController.cs
@@ -7,13 +7,24 @@ using Project_Unite.Models;
namespace Project_Unite.Controllers
{
+ [Authorize]
public class ContestsController : Controller
{
+ [AllowAnonymous]
// GET: Contests
public ActionResult Index()
{
var model = new ApplicationDbContext().Contests.ToArray();
return View(model);
}
+
+ public ActionResult ViewContest(string id)
+ {
+ var db = new ApplicationDbContext();
+ var c = db.Contests.FirstOrDefault(x => x.Id == id);
+ if (c == null)
+ return new HttpStatusCodeResult(404);
+ return View(c);
+ }
}
} \ No newline at end of file
diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj
index 2d40155..e9c5b83 100644
--- a/Project-Unite/Project-Unite.csproj
+++ b/Project-Unite/Project-Unite.csproj
@@ -968,6 +968,7 @@
<Content Include="Views\Home\AccessDenied.cshtml" />
<Content Include="Views\Home\SendFeedback.cshtml" />
<Content Include="Views\Contests\Index.cshtml" />
+ <Content Include="Views\Contests\ViewContest.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
diff --git a/Project-Unite/Views/Contests/ViewContest.cshtml b/Project-Unite/Views/Contests/ViewContest.cshtml
new file mode 100644
index 0000000..a78cdbc
--- /dev/null
+++ b/Project-Unite/Views/Contests/ViewContest.cshtml
@@ -0,0 +1,94 @@
+@model Project_Unite.Models.Contest
+@{
+ ViewBag.Title = "Contest: " + Model.Name;
+}
+
+<h2>@Model.Name</h2>
+
+<style>
+ .text-bronze {
+ color: #cd7f32;
+ }
+
+ .text-silver {
+ color: #C0C0C0;
+ }
+
+ .text-gold {
+ color: #FFD700;
+ }
+</style>
+
+
+<div class="row">
+ <div class="col-xs-9">
+ @if (!string.IsNullOrWhiteSpace(Model.VideoId))
+ {
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/@Model.VideoId" frameborder="0" allowfullscreen></iframe>
+
+ if (Model.IsEnded)
+ {
+ <h3>This contest has ended on @Model.EndsAt</h3>
+ }
+ else
+ {
+ <h3>This contest is open - and will be closed at @Model.EndsAt</h3>
+ }
+
+ <p>@Html.Markdown(Model.Description)</p>
+
+ <h3>Contest rewards:</h3>
+
+ <dl>
+ <dt class="text-gold">Gold:</dt><dd>@Model.CodepointReward1st Codepoints</dd>
+ <dt class="text-silver">Silver:</dt>
+ <dd>@Model.CodepointReward2nd Codepoints</dd>
+ <dt class="text-bronze">Bronze:</dt>
+ <dd>@Model.CodepointReward3rd Codepoints</dd>
+ </dl>
+ }
+ </div>
+ <div class="col-xs-3">
+ <h4>Want to win this contest?</h4>
+
+ @if (Model.IsEnded)
+ {
+ <p>Unfortunately, this contest has ended and you cannot submit an entry. Perhaps there's another contest still going?</p>
+ }
+ else
+ {
+ <p>Good news! This contest is still open. Hurry and submit your entry!</p>
+
+ <a href="@Url.Action("SubmitEntry", "Contests", new {id=Model.Id})" class="btn-primary btn"><span class="glyphicon glyphicon-arrow-right"></span> Go, go, go! Submit an entry!</a>
+ }
+
+ <h4>Current winners:</h4>
+
+ @{
+ var toptobottom = Model.Entries.OrderByDescending(x => (x.Upvotes.Length - x.Downvotes.Length));
+
+ }
+
+ @if(toptobottom.Count() >= 3)
+ {
+ var first = toptobottom.ToArray()[0];
+ var second = toptobottom.ToArray()[1];
+ var third = toptobottom.ToArray()[2];
+
+ <dl>
+ <dt class="text-gold">First place:</dt>
+ <dd>@first.Name by @Html.UserLink(first.AuthorId)</dd>
+ <dt class="text-silver">Second place:</dt>
+ <dd>@second.Name by @Html.UserLink(second.AuthorId)</dd>
+ <dt class="text-bronze">Third place:</dt>
+ <dd>@third.Name by @Html.UserLink(third.AuthorId)</dd>
+ </dl>
+ }
+ else
+ {
+ <p>Not enough people have entered into this contest.</p>
+ }
+
+ </div>
+</div>
+