diff options
| author | Michael <[email protected]> | 2017-04-14 14:22:51 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-14 14:22:51 -0400 |
| commit | 52245ffb86b6d1585c4e4c82e6bf1b3c03c8846a (patch) | |
| tree | ab8d55e8f76bdfa1f34705b60286a5da1a77bcc2 /Project-Unite/Models/BugModels.cs | |
| parent | c5506fc9f9efcf960cced980230d6c038b226f1a (diff) | |
| download | project-unite-52245ffb86b6d1585c4e4c82e6bf1b3c03c8846a.tar.gz project-unite-52245ffb86b6d1585c4e4c82e6bf1b3c03c8846a.tar.bz2 project-unite-52245ffb86b6d1585c4e4c82e6bf1b3c03c8846a.zip | |
Bugtracker work
Diffstat (limited to 'Project-Unite/Models/BugModels.cs')
| -rw-r--r-- | Project-Unite/Models/BugModels.cs | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/Project-Unite/Models/BugModels.cs b/Project-Unite/Models/BugModels.cs new file mode 100644 index 0000000..d109d2a --- /dev/null +++ b/Project-Unite/Models/BugModels.cs @@ -0,0 +1,124 @@ +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 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 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>(); + foreach(var itm in db.Downloads.OrderByDescending(x => x.PostDate)) + { + items.Add(new SelectListItem + { + Text = itm.Name, + Value = itm.Id + }); + } + return items; + } + } + } +}
\ No newline at end of file |
