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
137
138
139
140
141
142
143
144
145
146
147
|
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Project_Unite.Models
{
public class Bug
{
public string Id { get; set; }
/// <summary>
/// Just a funny name for "what category is this bug in?"
/// </summary>
public string Species { get; set; }
public int Urgency { get; set; }
public string Name { get; set; }
public ForumPost[] Comments
{
get
{
return new ApplicationDbContext().ForumPosts.Where(x => x.Parent == this.Id).ToArray();
}
}
public DateTime ReportedAt { get; set; }
public string ReleaseId { get; set; }
public string Reporter { get; set; }
public bool Open { get; set; }
public DateTime ClosedAt { get; set; }
public string ClosedBy { get; set; }
}
public class ViewBugViewModel
{
public Bug BugData { get; set; }
[AllowHtml]
[Required(AllowEmptyStrings =false, ErrorMessage ="Please enter a valid comment.")]
[MinLength(20, ErrorMessage = "Your comment must have at least 20 characters.")]
public string Comment { get; set; }
}
public class BugTag
{
public string Id { get; set; }
public string Name { get; set; }
public string ColorHex { get; set; }
public string Description { get; set; }
public Bug[] Open
{
get
{
return new ApplicationDbContext().Bugs.Where(x => x.Species == this.Id && x.Open == true).ToArray();
}
}
public Bug[] Closed
{
get
{
return new ApplicationDbContext().Bugs.Where(x => x.Species == this.Id && x.Open == false).ToArray();
}
}
}
public class PostBugViewModel
{
[Required(AllowEmptyStrings = false, ErrorMessage ="You must specify a name for your bug.")]
[MaxLength(75, ErrorMessage = "Your bug's name must have at most 75 characters.")]
public string Name { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage ="Please describe your bug.")]
[AllowHtml]
[MinLength(20, ErrorMessage = "Your bug's description must have at least 20 characters in it.")]
public string Description { get; set; }
public string SpeciesId { get; set; }
public string VersionId { get; set; }
public string Urgency { get; set; }
public List<SelectListItem> Urgencies
{
get
{
var items = new List<SelectListItem>();
string[] list = new[] { "Minor", "Moderate", "Major", "Critical" };
for (int i = 0; i < list.Length; i++)
{
items.Add(new SelectListItem
{
Text = list[i],
Value = i.ToString()
});
}
return items;
}
}
public List<SelectListItem> Species
{
get
{
var db = new ApplicationDbContext();
var items = new List<SelectListItem>();
foreach (var itm in db.BugTags.OrderBy(x => x.Name))
{
items.Add(new SelectListItem
{
Text = itm.Name,
Value = itm.Id
});
}
return items;
}
}
public List<SelectListItem> Versions
{
get
{
var db = new ApplicationDbContext();
var items = new List<SelectListItem>();
items.Add(new SelectListItem
{
Text = "No specific version",
Value = "none"
});
foreach(var itm in db.Downloads.Where(x=>x.Obsolete == false).OrderByDescending(x => x.PostDate))
{
items.Add(new SelectListItem
{
Text = itm.Name,
Value = itm.Id
});
}
return items;
}
}
}
}
|