Exemplo n.º 1
0
        // GET: Projects/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var project = db.Projects.Find(id);
            var selected = project.Users.Select(u => u.Id);
            ProjectUsersViewModel projectUser = new ProjectUsersViewModel()
            {
                Users = new MultiSelectList(db.Users.ToList(), "Id", "DisplayName", selected),
                Project = project
            };

            return View(projectUser);
        }
Exemplo n.º 2
0
        public ActionResult Edit(ProjectUsersViewModel projectUsers)
        {
            var proj = db.Projects.Find(projectUsers.Project.Id);
            ProjectUsersHelper myHelper = new ProjectUsersHelper();
            proj.Users.Clear();

            foreach(var UserId in projectUsers.SelectedUsers)
            {
                myHelper.AddUserToProject(UserId, proj.Id);
            }
            return RedirectToAction("Index");
        }