summaryrefslogtreecommitdiff
path: root/Project-Unite/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'Project-Unite/Controllers')
-rw-r--r--Project-Unite/Controllers/BugsController.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/BugsController.cs b/Project-Unite/Controllers/BugsController.cs
index 34de971..d7ee4e2 100644
--- a/Project-Unite/Controllers/BugsController.cs
+++ b/Project-Unite/Controllers/BugsController.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
+using Microsoft.AspNet.Identity;
using Project_Unite.Models;
namespace Project_Unite.Controllers
@@ -24,5 +25,36 @@ namespace Project_Unite.Controllers
return new HttpStatusCodeResult(404);
return View(cat);
}
+
+ public ActionResult ViewBug(string id)
+ {
+ var db = new ApplicationDbContext();
+ var bug = db.Bugs.FirstOrDefault(x => x.Id == id);
+ if (bug == null)
+ return new HttpStatusCodeResult(404);
+ var model = new ViewBugViewModel();
+ model.BugData = bug;
+ return View(model);
+ }
+
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ [Authorize]
+ public ActionResult ViewBug(ViewBugViewModel model)
+ {
+ if (!ModelState.IsValid)
+ return View(model);
+ var db = new ApplicationDbContext();
+ var post = new ForumPost();
+ post.Id = Guid.NewGuid().ToString();
+ post.AuthorId = User.Identity.GetUserId();
+ post.Body = model.Comment;
+ post.Parent = model.BugData.Id;
+ post.PostedAt = DateTime.Now;
+ db.ForumPosts.Add(post);
+ db.SaveChanges();
+ model.Comment = "";
+ return View(model);
+ }
}
} \ No newline at end of file