コード例 #1
0
        public ActionResult Team(int id)
        {
            var team = this.teamsService.GetTeamById(id);

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

            //Only Senior(enum 4), Intermediate(enum 5), Junior(enum 6) and Trainee(enum 7) can be added and removed from team.
            var freeEmployees = this.employeesService
                                .AllEmployees()
                                .Where(e => e.Position > CompanyRoleType.TeamLeader && e.Team == null)
                                .ToList();

            var teamMembers = this.teamsService.GetTeamById(id)
                              .Employees
                              .Where(e => e.Position != CompanyRoleType.TeamLeader)
                              .ToList();

            var freeProjects = this.projectsService
                               .AllProjects()
                               .Where(p => p.Status == ProjectStatus.NotStarted)
                               .ToList();

            var manageTeamViewModel = new TeamManageInputModel
            {
                FreeMembers  = this.employeesService.SelectListItemGenerator(freeEmployees),
                TeamMembers  = this.employeesService.SelectListItemGenerator(teamMembers),
                FreeProjects = this.projectsService.SelectListItemGenerator(freeProjects)
            };

            return(View(manageTeamViewModel));
        }
コード例 #2
0
        public ActionResult Team(int id, TeamManageInputModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var team = this.teamsService.GetTeamById(id);

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

            this.teamsService.AddTeamMemebers(team, model.TeamMembersToAdd);
            this.teamsService.RemoveTeamMemebers(team, model.TeamMembersToRemove);

            var projectToAdd = this.projectsService.AllProjects().FirstOrDefault(p => p.Id == model.ProjectToAdd);

            this.teamsService.AddProjectToTeam(team, projectToAdd);

            return(RedirectToAction(Constants.Index, Constants.Teams));
        }