public ActionResult Edit(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Projects project = db.Projects.Find(Id); if (project == null) { return(HttpNotFound()); } ProjectsHelper projectsHelper = new ProjectsHelper(db); var userId = User.Identity.GetUserId(); if (!projectsHelper.HasProject(userId, project.Id)) { TempData["Error"] = "Sorry, you do not have permission to access that project."; return(RedirectToAction("Index")); } return(View(project)); }
// GET: Projects/Details/5 public ActionResult Details(int?Id, string userId) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Projects project = db.Projects.Find(Id); if (project == null) { return(HttpNotFound()); } var tickets = project.Tickets.OrderByDescending(t => t.Created).ToList(); ProjectsHelper projectsHelper = new ProjectsHelper(db); userId = User.Identity.GetUserId(); if (!projectsHelper.HasProject(userId, project.Id)) { TempData["Error"] = "Sorry, you do not have permission to access that project."; return(RedirectToAction("Index")); } return(View(project)); }