blob: ef2cf854787b23764f9c492246f0594ad2e86afc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace Project_Unite.Models
{
public class CreateContestViewModel
{
[Required(AllowEmptyStrings =false, ErrorMessage ="You must name your contest!")]
[MinLength(5, ErrorMessage ="Your contest name must contain at least 5 characters.")]
[MaxLength(35, ErrorMessage ="Your contest's name must not have more than 35 characters!")]
public string Name { get; set; }
[AllowHtml]
[Required(AllowEmptyStrings = false, ErrorMessage = "Please describe your contest!")]
public string Description { get; set; }
[Required(ErrorMessage ="Please set an end date for the contest.")]
public DateTime EndDate { get; set; }
[Required(ErrorMessage ="Please specify a Codepoint reward for the gold winner.")]
public long GoldReward { get; set; }
[Required(ErrorMessage = "Please specify a Codepoint reward for the silver winner.")]
public long SilverReward { get; set; }
[Required(ErrorMessage = "Please specify a Codepoint reward for the bronze winner.")]
public long BronzeReward { get; set; }
public string VideoId { get; set; }
}
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 UserSubmitted(string uid)
{
return Entries.FirstOrDefault(x => x.AuthorId == uid) != null;
}
public bool IsEnded { get; set; }
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 string DisqualifiedBy { get; set; }
public string DisqualifiedReason { 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();
}
}
}
public class SubmitContestEntryViewModel
{
public string ContestId { get; set; }
public List<SelectListItem> Contests
{
get
{
var db = new ApplicationDbContext();
var list = new List<SelectListItem>();
foreach (var c in db.Contests.Where(x => x.IsEnded == false).OrderByDescending(x => x.StartedAt).ToArray())
{
list.Add(new SelectListItem
{
Value = c.Id,
Text = c.Name
});
}
return list;
}
}
[Required(AllowEmptyStrings =false, ErrorMessage ="Please name your submission!")]
[MaxLength(55, ErrorMessage ="Your submission's name must have less than 55 characters in it.")]
[MinLength(5, ErrorMessage ="Your submission's name must be at least 5 characters long.")]
public string Name { get; set; }
[Required(AllowEmptyStrings =false, ErrorMessage ="Please describe your submission!")]
[AllowHtml]
public string Description { get; set; }
public HttpPostedFileBase Download { get; set; }
public string VideoID { get; set; }
}
}
|