public ActionResult Details(int id)
        {
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Value");
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatus, "Id", "Value");
            ViewBag.TicketTypeId     = new SelectList(db.TicketTypes, "Id", "Value");

            //Let's see if an eager loading of the related Ticket data solves our issue...
            //Project project = db.Projects.Find(id);

            var project = db.Projects.Find(id);


            var usersOnProject = projectHelper.ListUsersOnProject(id);

            if (project == null)
            {
                return(HttpNotFound());
            }
            var userId = User.Identity.GetUserId();
            var myRole = roleHelper.ListUserRoles(userId).ToList().FirstOrDefault();

            switch (myRole)
            {
            case "ProjectManager":
                if (project.AssignedUserId != userId && project.OwnerUserId != userId)
                {
                    return(RedirectToAction("ProfileView", "Account"));
                }
                break;

            case "Developer":
                if (project.AssignedUserId != userId)
                {
                    return(RedirectToAction("ProfileView", "Account"));
                }
                break;

            case "Submitter":
                if (project.AssignedUserId != userId)
                {
                    return(RedirectToAction("ProfileView", "Account"));
                }
                break;

            default:
                break;
            }
            return(View(project));
        }
Exemplo n.º 2
0
        public ActionResult ProjectAssignment(int projects, List <string> users)
        {
            //Remove any and all current role assignment
            var projectUsers = projectsHelper.ListUsersOnProject(projects);

            if (projectUsers.Count > 0)
            {
                foreach (var user in projectUsers.ToList())
                {
                    projectsHelper.RemoveUserFromProject(user.Id, projects);
                }
            }
            foreach (var userId in users)
            {
                projectsHelper.AddUserToProject(userId, projects);
            }
            return(RedirectToAction("Index", "Projects"));
        }