mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 11:21:47 -05:00
Contests index page
This commit is contained in:
parent
9b06522c66
commit
92bda00b05
5 changed files with 224 additions and 0 deletions
19
Project-Unite/Controllers/ContestsController.cs
Normal file
19
Project-Unite/Controllers/ContestsController.cs
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
70
Project-Unite/Models/ContestModels.cs
Normal file
70
Project-Unite/Models/ContestModels.cs
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -244,6 +244,8 @@ public static ApplicationDbContext Create()
|
|||
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; }
|
||||
|
|
|
@ -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\" />
|
||||
|
|
130
Project-Unite/Views/Contests/Index.cshtml
Normal file
130
Project-Unite/Views/Contests/Index.cshtml
Normal file
|
@ -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 • Ends at @c.EndsAt</p>
|
||||
<p><strong>Rewards: </strong> <em class="text-gold">Gold: @c.CodepointReward1st CP</em> • <em class="text-silver">Gold: @c.CodepointReward2nd CP</em> • <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/watch?v=@c.VideoId" 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 • Ends at @c.EndsAt</p>
|
||||
<p><strong>Rewards: </strong> <em class="text-gold">Gold: @c.CodepointReward1st CP</em> • <em class="text-silver">Gold: @c.CodepointReward2nd CP</em> • <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/watch?v=@c.VideoId" class="btn btn-default"><span class="glyphicon glyphicon-hd-video"></span> Watch video</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue