From 54f52b10a64b564aef489310da29b12d64c4ec18 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 21 May 2017 08:12:24 -0400 Subject: [PATCH] viewsubmission screen --- .../Controllers/ContestsController.cs | 9 ++ Project-Unite/Project-Unite.csproj | 1 + .../Views/Contests/ViewSubmission.cshtml | 83 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Project-Unite/Views/Contests/ViewSubmission.cshtml diff --git a/Project-Unite/Controllers/ContestsController.cs b/Project-Unite/Controllers/ContestsController.cs index 1d403f2..b4315d3 100644 --- a/Project-Unite/Controllers/ContestsController.cs +++ b/Project-Unite/Controllers/ContestsController.cs @@ -29,6 +29,15 @@ public ActionResult ViewContest(string id) return View(c); } + public ActionResult ViewSubmission(string id) + { + var db = new ApplicationDbContext(); + var e = db.ContestEntries.FirstOrDefault(x => x.Id == id); + if (e == null) + return new HttpStatusCodeResult(404); + return View(e); + } + [RequiresAdmin] public ActionResult CloseContest(string id) { diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index 3ecbf96..c8e3dd6 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -973,6 +973,7 @@ + diff --git a/Project-Unite/Views/Contests/ViewSubmission.cshtml b/Project-Unite/Views/Contests/ViewSubmission.cshtml new file mode 100644 index 0000000..47cdaed --- /dev/null +++ b/Project-Unite/Views/Contests/ViewSubmission.cshtml @@ -0,0 +1,83 @@ +@using Microsoft.AspNet.Identity +@model Project_Unite.Models.ContestEntry +@{ + ViewBag.Title = Model.Name; + string uvurl = Url.Action("Upvote", new { id = Model.Id }); + string dvurl = Url.Action("Downvote", new { id = Model.Id }); + + if (Model.AuthorId == User.Identity.GetUserId()) + { + uvurl = "#"; + dvurl = "#"; + } + string uid = User.Identity.GetUserId(); + if(Model.Upvotes.FirstOrDefault(x=>x.User==uid) != null) + { + uvurl = uvurl.Replace("Upvote", "RemoveVote"); + } + if (Model.Downvotes.FirstOrDefault(x => x.User == uid) != null) + { + dvurl = dvurl.Replace("Upvote", "RemoveVote"); + } + +} + + +

@Model.Name

+ +

Submitted by @Html.UserLink(Model.AuthorId) on @Model.PostedAt

+ +
+
+

Submission details

+ + @if (!string.IsNullOrWhiteSpace(Model.VideoId)) + { + + } + + + +

@Html.Markdown(Model.Description)

+
+
+

How to win a contest...

+ +

We choose contest winners based on quality of the content and submission, as well as what the community thinks of the submission. If you get a lot of downvotes it is likely you will not win. However, if you are mass-downvoting to make yourself look better to the algorithm, you will be disqualified.

+ +

Download this submission

+ + @if (!string.IsNullOrWhiteSpace(Model.DownloadURL)) + { + Download this submission + } + else + { +

The author of this submission hasn't provided a download.

+ } + + @if (Model.Disqualified) + { +

This submission has been disqualified by @Html.UserLink(Model.DisqualifiedBy).

+ +

This submission has been disqualified and will not be able to win.

+ +
Reason:
+ +

@Model.DisqualifiedReason

+ } + else + { + if (User.Identity.IsAdmin()) + { +

Did it meet the criteria?

+

If this submission didn't meet the criteria for its contest, you may disqualify it using this button.

+ Disqualify + } + } + +
+
\ No newline at end of file