Exemple #1
0
        public ActionResult AssignProjectUsers(int id, string ProjectManager, List <string> Submitters, List <string> Developers)
        {
            //Before we assign anybody to the project we first need to unassign everybody from the project

            foreach (var user in projectHelper.UsersOnProject(id).ToList())
            {
                projectHelper.RemoveUserFromProject(user.Id, id);
            }

            projectHelper.AddUserToProject(ProjectManager, id);

            if (Submitters != null)
            {
                foreach (var user in Submitters)
                {
                    projectHelper.AddUserToProject(user, id);
                }
            }

            if (Developers != null)
            {
                foreach (var user in Developers)
                {
                    projectHelper.AddUserToProject(user, id);
                }
            }

            return(View());
        }
Exemple #2
0
        public ActionResult AssignDEV(ProjectDevViewModel model)
        {
            ProjectHelpers helper = new ProjectHelpers();

            if (ModelState.IsValid)
            {
                var prj = db.Projects.Find(model.Project.Id);
                foreach (var usr in prj.Users)
                {
                    helper.RemoveUserFromProject(usr.Id, prj.Id);
                }

                foreach (var dev in model.SelectedUsers)
                {
                    helper.AddUserToProject(dev, model.Project.Id);
                }

                //db.SaveChanges();

                return(RedirectToAction("Details", new { id = model.Project.Id }));
            }
            return(View(model.Project.Id));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "Id,Name,Description")] Project project, List <string> Developers, List <string> Submitters, string ProjManager)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                db.SaveChanges();
                if (User.IsInRole("PM"))
                {
                    projecthelper.AddUserToProject(User.Identity.GetUserId(), project.Id);
                }

                else
                {
                    if (string.IsNullOrEmpty(ProjManager))
                    {
                        projecthelper.AddUserToProject(ProjManager, project.Id);
                    }
                }

                if (Developers != null)
                {
                    foreach (var dev in Developers)
                    {
                        projecthelper.AddUserToProject(dev, project.Id);
                    }
                }
                if (Submitters != null)
                {
                    foreach (var sub in Submitters)
                    {
                        projecthelper.AddUserToProject(sub, project.Id);
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(project));
        }