public ActionResult AddDEV(int id)
        {
            ProjectDevViewModel vm      = new ProjectDevViewModel();
            UserRolesHelper     helper  = new UserRolesHelper();
            ProjectsHelper      pHelper = new ProjectsHelper();

            var dev     = helper.UsersInRole("Developer");
            var projdev = pHelper.ProjectUsersByRole(id, "Developer").Select(u => u.Id).ToArray();

            vm.DevUsers = new MultiSelectList(dev, "Id", "FirstName", projdev);
            vm.Project  = db.Projects.Find(id);

            return(View(vm));
        }
Esempio n. 2
0
        public ActionResult AssignDev(int id)
        {
            ProjectDevViewModel vm = new ProjectDevViewModel();
            UserRolesHelper     rh = new UserRolesHelper();
            ProjectHelper       ph = new ProjectHelper();

            var dev        = rh.UsersInRole("Developer");
            var projectDev = ph.ProjectUsersByRole(id, "Developer").Select(u => u.Id).ToArray();

            vm.DevUsers = new MultiSelectList(dev, "Id", "FullName", projectDev);
            vm.project  = db.Projects.Find(id);

            return(View(vm));
        }
Esempio n. 3
0
        public ActionResult AssignDev(ProjectDevViewModel model)
        {
            ProjectHelper ph = new ProjectHelper();

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

                foreach (var dev in model.SelectedUsers)
                {
                    ph.AddUserToProject(dev, model.project.Id);
                }
            }
            return(RedirectToAction("Details", new { id = model.project.Id }));
        }
Esempio n. 4
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));
        }