diff --git a/Project-Unite/Controllers/BugsController.cs b/Project-Unite/Controllers/BugsController.cs index d7ee4e2..2d9250f 100644 --- a/Project-Unite/Controllers/BugsController.cs +++ b/Project-Unite/Controllers/BugsController.cs @@ -56,5 +56,79 @@ public ActionResult ViewBug(ViewBugViewModel model) model.Comment = ""; return View(model); } + + [Authorize] + public ActionResult OpenBug(string id) + { + var db = new ApplicationDbContext(); + var bug = db.Bugs.FirstOrDefault(x => x.Id == id); + if (bug == null) + return new HttpStatusCodeResult(404); + bug.Open = true; + db.SaveChanges(); + return RedirectToAction("ViewCategory", new { id = bug.Species }); + } + + [Authorize] + public ActionResult CloseBug(string id) + { + var db = new ApplicationDbContext(); + var bug = db.Bugs.FirstOrDefault(x => x.Id == id); + if (bug == null) + return new HttpStatusCodeResult(404); + bug.Open = false; + bug.ClosedAt = DateTime.Now; + bug.ClosedBy = User.Identity.GetUserId(); + db.SaveChanges(); + return RedirectToAction("ViewCategory", new { id = bug.Species }); + } + + [Authorize] + public ActionResult PostBug() + { + var model = new PostBugViewModel(); + return View(model); + } + + [Authorize] + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult PostBug(PostBugViewModel model) + { + if (!ModelState.IsValid) + return View(model); + var db = new ApplicationDbContext(); + var bug = new Bug(); + bug.Name = model.Name; + + string allowed = "abcdefghijklmnopqrstuvwxyz1234567890_-"; + + string id = bug.Name.ToLower() + "_" + db.Bugs.Count().ToString(); + + foreach(var c in id.ToCharArray()) + { + if (!allowed.Contains(c)) + id = id.Replace(c, '_'); + } + + bug.Id = id; + bug.Open = true; + bug.Reporter = User.Identity.GetUserId(); + bug.ReportedAt = DateTime.Now; + bug.Species = model.SpeciesId; + bug.Urgency = int.Parse(model.Urgency); + bug.ReleaseId = model.VersionId; + var comment = new ForumPost(); + comment.AuthorId = User.Identity.GetUserId(); + comment.Body = model.Description; + comment.Id = Guid.NewGuid().ToString(); + comment.Parent = bug.Id; + comment.PostedAt = DateTime.Now; + db.ForumPosts.Add(comment); + db.Bugs.Add(bug); + db.SaveChanges(); + + return RedirectToAction("ViewBug", new { id = bug.Id }); + } } } \ No newline at end of file diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index f7e54ed..cb3bfb3 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -566,6 +566,7 @@ + diff --git a/Project-Unite/Views/Bugs/PostBug.cshtml b/Project-Unite/Views/Bugs/PostBug.cshtml new file mode 100644 index 0000000..b086947 --- /dev/null +++ b/Project-Unite/Views/Bugs/PostBug.cshtml @@ -0,0 +1,66 @@ +@model Project_Unite.Models.PostBugViewModel +@{ + ViewBag.Title = "Post a bug"; +} + +

Post a bug

+ +

Found a crash? Something inconsistent? Inconvenient? Whatever it is, we wanna know so we can fix it.

+ +

Just fill out this quick form.

+ +@using (Html.BeginForm()) +{ + @Html.AntiForgeryToken() +
+
+ @Html.ValidationSummary() +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Name:@Html.TextBoxFor(Model=>Model.Name, new { @class = "form-control" })
Version:
+ What version of ShiftOS did you experience this bug in?
@Html.DropDownListFor(Model=>Model.VersionId, Model.Versions, new{@class="form-control"})
+ Urgency:
+ How bad of a bug is this? +
@Html.DropDownListFor(Model => Model.Urgency, Model.Urgencies, new { @class = "form-control" })
+ Category:
+ What species of bug is this? (Hah, I'm tying biology into programming terms.) +
@Html.DropDownListFor(Model => Model.SpeciesId, Model.Species, new { @class = "form-control" })
Details:
+ Here you can supply as much detail as you want about the bug. Screenshots, links, explanations, crashes, logs, etc. The more info there is, the more we can help.

+ Markdown formatting is supported.
@Html.TextAreaFor(Model=>Model.Description, new { @class = "form-control", rows = "5" })
+ +

Note on Rolling Release Builds

+ +

It's worth noting that rolling release builds follow the same bug support as the latest version of the standard-release ShiftOS. So, if you are running on the rolling release version, and the latest version is Beta 2, submit the bug for Beta 2.

+ +

My version of the game is not showing!

+ +

Note that obsolete versions of ShiftOS are not supported by us anymore, and thus, you may not submit a bug report for these versions.

+ +

Also, any forked versions of ShiftOS are not supported by us. It is up to the developers of the fork to maintain their releases, keep their codebase in sync with ours, and take care of bugs that we don't cover.

+} \ No newline at end of file