summaryrefslogtreecommitdiff
path: root/Project-Unite/Models
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-20 20:06:42 -0400
committerMichael <[email protected]>2017-05-20 20:06:42 -0400
commite37b3223dbcd7957bbe113c5cb9a5698205fb722 (patch)
treebb6abeb3f6cf408b69745331fd09bb7fcca0f48e /Project-Unite/Models
parentb0c200196e5506b456895f9ee0c4c8dcd547fdb7 (diff)
downloadproject-unite-e37b3223dbcd7957bbe113c5cb9a5698205fb722.tar.gz
project-unite-e37b3223dbcd7957bbe113c5cb9a5698205fb722.tar.bz2
project-unite-e37b3223dbcd7957bbe113c5cb9a5698205fb722.zip
create contest page
Diffstat (limited to 'Project-Unite/Models')
-rw-r--r--Project-Unite/Models/ContestModels.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/Project-Unite/Models/ContestModels.cs b/Project-Unite/Models/ContestModels.cs
index 80533c1..6af7aca 100644
--- a/Project-Unite/Models/ContestModels.cs
+++ b/Project-Unite/Models/ContestModels.cs
@@ -2,9 +2,58 @@
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; }
+
+ 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;
+ }
+ }
+
+ [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; }