Beispiel #1
0
        // GET: Projects for a User
        public ActionResult UserProjectsOnly()
        {
            var userID = User.Identity.GetUserId();
            //pass in userId, check their role, and then show them relevant projects.
            //admin and PM see all projects
            var projs = db.Projects.ToList();
            List <ProjectPMViewModel> model = new List <ProjectPMViewModel>();

            foreach (var p in projs)
            {
                ProjectsHelper Phelper = new ProjectsHelper();
                if (Phelper.IsUserOnProject(userID, p.Id))
                {
                    ProjectPMViewModel vm = new ProjectPMViewModel();
                    vm.Project = p;
                    //this works because the PMID is just the User.Id, which is the primary key of Users
                    //this code adds the user
                    vm.ProjectManager = p.PMID != null?db.Users.Find(p.PMID) : null;

                    model.Add(vm);
                }
            }


            return(View(model));
        }
Beispiel #2
0
        // GET: Projects
        public ActionResult Index()
        {
            var projs = db.Projects.ToList();
            List <ProjectPMViewModel> model = new List <ProjectPMViewModel>();

            foreach (var p in projs)
            {
                ProjectPMViewModel vm = new ProjectPMViewModel();
                vm.project        = p;
                vm.ProjectManager = p.PMID != null?db.Users.Find(p.PMID) : null;

                model.Add(vm);
            }
            return(View(model));
        }
Beispiel #3
0
        public ActionResult Index()
        {
            //pass in userId, check their role, and then show them relevant projects.
            //admin and PM see all projects
            var projs = db.Projects.ToList();
            List <ProjectPMViewModel> model = new List <ProjectPMViewModel>();

            foreach (var p in projs)
            {
                ProjectPMViewModel vm = new ProjectPMViewModel();
                vm.Project = p;
                //this works because the PMID is just the User.Id, which is the primary key of Users
                vm.ProjectManager = p.PMID != null?db.Users.Find(p.PMID) : null;

                model.Add(vm);
            }


            return(View(model));
        }