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

                AssignProjectUsersViewModel model  = new AssignProjectUsersViewModel();
                ProjectUsersHelper          helper = new ProjectUsersHelper(db);
                model.ProjectId    = project.Id;
                model.ProjectTitle = project.Title;
                var currentUsers = helper.ListUsers(model.ProjectId);
                model.UsersList    = currentUsers;
                model.CurrentUsers = new SelectList(currentUsers, "Id", "FullName");
                var absentUsers = helper.ListAbsentUsers(model.ProjectId);
                model.AbsentUsers = new SelectList(absentUsers, "Id", "FullName");
                return(View(model));
            }
        }
コード例 #2
0
        public ActionResult AssignUser(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ticket ticket = db.Tickets.Find(id);

            if (ticket == null)
            {
                return(HttpNotFound());
            }
            AssignTicketUserViewModel AssignModel = new AssignTicketUserViewModel();

            AssignModel.TicketId    = ticket.Id;
            AssignModel.TicketTitle = ticket.Title;
            ProjectUsersHelper helper     = new ProjectUsersHelper(db);
            UserRolesHelper    userHelper = new UserRolesHelper(db);
            var projectUsers      = helper.ListUsers(ticket.ProjectId);
            var projectDevelopers = new List <ApplicationUser>();

            foreach (var user in projectUsers)
            {
                if (userHelper.IsUserInRole(user.Id, "Developer"))
                {
                    projectDevelopers.Add(user);
                }
            }
            if (ticket.Assignee != null)
            {
                AssignModel.TicketAssignedTo = ticket.Assignee.FullName;
            }
            AssignModel.UsersList = new SelectList(projectDevelopers, "Id", "FullName");
            return(View(AssignModel));
        }