public ActionResult Edit(EditBugModel model, int BugID) { if (ModelState.IsValid) { BugReporter_v2.DAL.BugDAL.EditBug(model.ProjectID, model.Owner, model.Status, model.Desctiption, model.Priority, BugID); var bug = BugReporter_v2.DAL.BugDAL.GetBugByID(BugID); if (String.IsNullOrEmpty(User.Identity.Name)) { return(HttpNotFound()); } LogDAL.AddLogForBug(User.Identity.Name, bug.BugId, "Edit"); UserDAL.AddActivity(User.Identity.Name); return(RedirectToAction("Index", "Bug")); } else { // If we got this far, something failed, redisplay form UserDAL.AddActivity(User.Identity.Name); ModelState.AddModelError("", "Error please try again"); ViewBag.Projects = new SelectList(db.Projects.OrderBy(x => x.ProjectName).Select(x => x), "ProjectId", "ProjectName", model.ProjectID); ViewBag.Users = new SelectList(db.UserProfiles.OrderBy(x => x.UserName).Select(x => x), "UserId", "UserName", model.Owner); ViewBag.BugID = BugID; return(View(model)); } }
public ActionResult Delete(int BugId = 0) { var bug = BugReporter_v2.DAL.BugDAL.GetBugByID(BugId); RouteValueDictionary routeValues; if (bug == null) { routeValues = this.GridRouteValues(); return(RedirectToAction("Index", routeValues)); } LogDAL.AddLogForBug(User.Identity.Name, bug.BugId, "Delete"); UserDAL.AddActivity(User.Identity.Name); BugDAL.DeleteBug(BugId); routeValues = this.GridRouteValues(); return(RedirectToAction("Index", routeValues)); }
public ActionResult Create(CreateBugModel model) { if (ModelState.IsValid) { BugReporter_v2.DAL.BugDAL.SubmitBugToProject(model.ProjectID, User.Identity.Name, "New", model.Desctiption, model.Priority); var bug = BugReporter_v2.DAL.BugDAL.GetLastAddedBug().First(); //BugReporter_v2.DAL.UserProfile user = User.Identity.Name; LogDAL.AddLogForBug((string)User.Identity.Name, bug.BugId, "Add"); UserDAL.AddActivity(User.Identity.Name); return(RedirectToAction("Index", "Home")); } else { // If we got this far, something failed, redisplay form ViewBag.error = "error"; UserDAL.AddActivity(User.Identity.Name); ModelState.AddModelError("", "Error please try again"); ViewBag.Projects = new SelectList(db.Projects.OrderBy(x => x.ProjectName).Select(x => x), "ProjectId", "ProjectName", model.ProjectID); return(View(model)); } }