Example #1
0
        public ActionResult Edit(int?id)
        {
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            ProjectUserHelper    helper      = new ProjectUserHelper(db);
            var user      = db.Users.Find(User.Identity.GetUserId());
            var userRoles = rolesHelper.ListUserRoles(user.Id);
            var tickets   = db.Tickets.Include(t => t.Assignee).Include(t => t.Project).Include(t => t.Priority).Include(t => t.Status).Include(t => t.Type);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ticket ticket = db.Tickets.Find(id);

            if (ticket == null)
            {
                return(HttpNotFound());
            }



            ViewBag.AssigneeId = new SelectList(rolesHelper.UsersInRole("Developer"), "Id", "DisplayName", ticket.AssigneeId);
            ViewBag.ProjectId  = new SelectList(helper.AssignedProjects(user.Id), "Id", "Title", ticket.ProjectId);
            ViewBag.PriorityId = new SelectList(db.Priorities, "Id", "Name", ticket.PriorityId);
            ViewBag.TypeId     = new SelectList(db.Types, "Id", "Name", ticket.TypeId);
            ViewBag.StatusId   = new SelectList(db.Status, "Id", "Name", ticket.StatusId);

            if (ticket == null)
            {
                return(HttpNotFound());
            }
            if (userRoles.Contains("ProjectManager"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Admin"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Developer"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Submitter"))
            {
                return(View(ticket));
            }

            return(RedirectToAction("Login", "Account"));
        }
Example #2
0
        public ActionResult Edit(int?id)
        {
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            ProjectUserHelper    helper      = new ProjectUserHelper(db);
            var user      = db.Users.Find(User.Identity.GetUserId());
            var userRoles = rolesHelper.ListUserRoles(user.Id);
            var tickets   = db.Tickets.Include(t => t.Assignee).Include(t => t.Project).Include(t => t.Priority).Include(t => t.Status).Include(t => t.Type);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ticket ticket = db.Tickets.Find(id);

            if (ticket == null)
            {
                return(HttpNotFound());
            }

            //Load up the Multi Select list with Developers only
            //var developers = new List<ApplicationUser>();
            //var allUsers = db.Users.ToList();
            //foreach (var person in allUsers)
            //{
            //    if (rolesHelper.IsUserInRole(person.Id, "Developer"))
            //    {
            //        developers.Add(person);
            //    }
            //}
            //ViewBag.AssignedToUserId = new SelectList(developers, "Id", "DisplayName", ticket.AssigneeId);

            ViewBag.AssigneeId = new SelectList(rolesHelper.UsersInRole("Developer"), "Id", "DisplayName", ticket.AssigneeId);
            ViewBag.ProjectId  = new SelectList(helper.AssignedProjects(user.Id), "Id", "Title", ticket.PriorityId);

            //ViewBag.AssigneeId = new SelectList(db.Users, "Id", "FirstName", ticket.AssigneeId);
            //ViewBag.AuthorId = new SelectList(db.Users, "Id", "FirstName", ticket.AuthorId);
            //ViewBag.AuthorId = user.FirstName;
            ViewBag.PriorityId = new SelectList(db.Priorities, "Id", "Name", ticket.PriorityId);
            //ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Title", ticket.ProjectId);
            ViewBag.TypeId   = new SelectList(db.Types, "Id", "Name", ticket.TypeId);
            ViewBag.StatusId = new SelectList(db.Status, "Id", "Name", ticket.StatusId);

            if (ticket == null)
            {
                return(HttpNotFound());
            }
            if (userRoles.Contains("ProjectManager"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Admin"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Developer"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Submitter"))
            {
                return(View(ticket));
            }

            return(RedirectToAction("Login", "Account"));
        }