summaryrefslogtreecommitdiff
path: root/Project-Unite/Models/ContestModels.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Project-Unite/Models/ContestModels.cs')
-rw-r--r--Project-Unite/Models/ContestModels.cs70
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