示例#1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Project project = db.Projects.Find(id);

            if (project == null)
            {
                return(HttpNotFound());
            }

            //var user = db.Users.Find(id);
            ProjectViewModel  ProjectModel = new ProjectViewModel();
            ProjectUserHelper helper       = new ProjectUserHelper(db);

            ProjectModel.Project = project;
            var currentUsers = helper.ListUsers(id);

            ProjectModel.Users = new MultiSelectList(currentUsers, "Id", "FirstName");

            var absentUsers = helper.AbsentUsers(id);

            ProjectModel.AbsentUsers = new MultiSelectList(absentUsers, "Id", "FirstName");


            return(View(ProjectModel));

            //return View(project);
        }
示例#2
0
        public ActionResult RemoveUsers(int pId, string[] usersToRemove)
        {
            var helper = new ProjectUserHelper();

            if (usersToRemove == null)
            {
                //var usersToRemove = helper.UsersInProject(pId);
                //foreach (var user in usersToRemove)
                //{
                //    helper.RemoveUserFromProject(user, pId);
                //}
                return(RedirectToAction("Edit", new { projectId = pId }));
            }
            else
            {
                for (var i = 0; i < usersToRemove.Length; i++)
                {
                    if (helper.IsUserInProject(usersToRemove[i], pId))
                    {
                        helper.RemoveUserFromProject(usersToRemove[i], pId);
                    }
                }
                return(RedirectToAction("Edit", new { projectId = pId }));
            }
        }
示例#3
0
        public ActionResult Edit(int?projectId)
        {
            if (projectId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var     projectModel = new ProjectUserViewModel();
            Project project      = db.Projects.Find(projectId);
            var     helper       = new ProjectUserHelper();

            // make sure project exists
            if (project != null)
            {
                projectModel.ProjectId   = project.Id;
                projectModel.ProjectName = project.Name;
                //get the user Ids that are associated with the project
                var userIdList   = helper.UsersInProject((int)projectId);
                var userInfoList = helper.getUserInfo(userIdList);
                projectModel.UsersAssignedtoProject = new MultiSelectList(userInfoList, "UserId", "UserName");

                //get the user Ids not associated with the project
                var nonUserIdList   = helper.UsersNotInProject((int)projectId);
                var nonUserInfoList = helper.getUserInfo(nonUserIdList);
                projectModel.UsersNotAssignedToProject = new MultiSelectList(nonUserInfoList, "UserId", "UserName");
                return(View(projectModel));
            }
            else
            {
                return(HttpNotFound());
            }
        }
        public ActionResult AssignUser(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ticket ticket = db.Tickets.Find(id);
            var    model  = new TicketAssignViewModel();

            model.TicketDetails = new TicketDetailsViewModel(ticket);
            if (!string.IsNullOrEmpty(ticket.AssignedToUserId))
            {
                model.SelectedUser = ticket.AssignedToUserId;
            }
            var helper       = new ProjectUserHelper();
            var uIdList      = helper.UsersInProject(ticket.ProjectId);
            var userInfoList = helper.getUserInfo(uIdList);

            if (!string.IsNullOrEmpty(model.SelectedUser))
            {
                model.ProjUsersList = new SelectList(userInfoList, "UserId", "UserName", model.SelectedUser);
            }
            else
            {
                model.ProjUsersList = new SelectList(userInfoList, "UserId", "UserName");
            }
            if (ticket == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
 public ActionResult Edit([Bind(Include = "Id,ProjectId,UserId")] ProjectUser projectUser)
 {
     if (ModelState.IsValid)
     {
         ProjectUserHelper.Edit(projectUser.Id, projectUser.ProjectId, projectUser.UserId);
         return(RedirectToAction("Index"));
     }
     ViewBag.ProjectId = new SelectList(ProjectHelper.GetProjects(), "Id", "Name", projectUser.ProjectId);
     ViewBag.UserId    = new SelectList(UserHelper.GetAllUsers(), "Id", "Email", projectUser.UserId);
     return(View(projectUser));
 }
        // GET: ProjectUsers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectUser projectUser = ProjectUserHelper.GetProjectUser(id);

            if (projectUser == null)
            {
                return(HttpNotFound());
            }
            return(View(projectUser));
        }
        // GET: ProjectUsers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectUser projectUser = ProjectUserHelper.GetProjectUser(id);

            if (projectUser == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProjectId = new SelectList(ProjectHelper.GetProjects(), "Id", "Name", projectUser.ProjectId);
            ViewBag.UserId    = new SelectList(UserHelper.GetAllUsers(), "Id", "Email", projectUser.UserId);
            return(View(projectUser));
        }
示例#8
0
        public ActionResult RemoveUser(int projectId, List <string> SelectedCurrentUsers)
        {
            if (ModelState.IsValid)
            {
                ProjectUserHelper helper = new ProjectUserHelper(db);
                var project = db.Projects.Find(projectId);



                if (SelectedCurrentUsers != null)
                {
                    foreach (var user in SelectedCurrentUsers)
                    {
                        helper.RemoveUser(user, projectId);
                    }
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View("Index"));
        }
 // GET: ProjectUsers
 public ActionResult Index()
 {
     return(View(ProjectUserHelper.GetProjectUsers()));
 }
 public ActionResult DeleteConfirmed(int id)
 {
     ProjectUserHelper.Delete(id);
     return(RedirectToAction("Index"));
 }