Пример #1
0
        public ActionResult AssignProjects(int projectId)
        {
            var project     = db.Projects.Find(projectId);
            var user        = db.Users.Find(User.Identity.GetUserId());
            var projectUser = new AdminProjectAssignModel();

            projectUser.project       = project;
            projectUser.user          = user;
            projectUser.SelectedUsers = project.Users.Select(u => u.Id).ToArray();
            projectUser.ProjUsers     = new MultiSelectList(db.Users, "Id", "Fullname", projectUser.SelectedUsers);
            return(View(projectUser));
        }
Пример #2
0
        public ActionResult AssignProjects(AdminProjectAssignModel model)
        {
            foreach (var user in db.Users.ToList())
            {
                userProjects.RemoveUserFromProject(user.Id, model.project.Id);
            }

            if (model.SelectedUsers != null)
            {
                foreach (var projectAdd in model.SelectedUsers)
                {
                    userProjects.AddUserToProject(projectAdd, model.project.Id);
                }
            }



            return(RedirectToAction("Index", "Projects"));
        }