diff options
| author | Michael <[email protected]> | 2017-05-20 19:23:42 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-20 19:23:42 -0400 |
| commit | 92bda00b054276e09f0f80b01af91bc3fedbd5b6 (patch) | |
| tree | e51d82ad623a745dde4edc80c9936cb0ba82f002 /Project-Unite/Models/ContestModels.cs | |
| parent | 9b06522c668ff8d2c27367529553eab6bded2021 (diff) | |
| download | project-unite-92bda00b054276e09f0f80b01af91bc3fedbd5b6.tar.gz project-unite-92bda00b054276e09f0f80b01af91bc3fedbd5b6.tar.bz2 project-unite-92bda00b054276e09f0f80b01af91bc3fedbd5b6.zip | |
Contests index page
Diffstat (limited to 'Project-Unite/Models/ContestModels.cs')
| -rw-r--r-- | Project-Unite/Models/ContestModels.cs | 70 |
1 files changed, 70 insertions, 0 deletions
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 |
