summaryrefslogtreecommitdiff
path: root/Project-Unite/Models
diff options
context:
space:
mode:
Diffstat (limited to 'Project-Unite/Models')
-rw-r--r--Project-Unite/Models/ContestModels.cs70
-rw-r--r--Project-Unite/Models/IdentityModels.cs2
2 files changed, 72 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
diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs
index 68c21fe..8959a8e 100644
--- a/Project-Unite/Models/IdentityModels.cs
+++ b/Project-Unite/Models/IdentityModels.cs
@@ -244,6 +244,8 @@ namespace Project_Unite.Models
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; }