Esempio n. 1
0
        // GET: Project/Details/5
        public ActionResult Details(int id)
        {
            ProjectService  projrepo = new ProjectService();
            EmployeeService repemp   = new EmployeeService();

            CD.Project            project     = projrepo.Get(id);
            TaskService           repoTask    = new TaskService();
            TaskStateService      repoTS      = new TaskStateService();
            TeamService           teamrepo    = new TeamService();
            MessageService        repoMessage = new MessageService();
            DocumentService       repoDoc     = new DocumentService();
            IEnumerable <CD.Task> tasks       = repoTask.GetByProjectId(id);

            /*--------------Possible mainTasks.groupJoin(tasks) pour arboresence?...
             * IEnumerable<Task> mainTasks = tasks.Where(t => t.MainTaskId == null);*/

            List <TaskListItem> taskList = new List <TaskListItem>();

            foreach (CD.Task t in tasks)
            {
                M.CurrentOn  currentOn    = (t.TaskTeam)?new M.CurrentOn(teamrepo.GetByTaskId(t.Id)):new M.CurrentOn(repemp.GetByTaskId(t.Id));
                TaskListItem taskListItem = new TaskListItem(new M.TaskWithState(t, repoTS.GetByTaskId(t.Id)), currentOn);
                taskList.Add(taskListItem);
            }

            IEnumerable <CD.Team> teams = teamrepo.GetByProjectId(id);//prendre un iEINumeralbe de team qui correspond à l'ensemble des equipes, faisant partie d'un seul et même projet

            /*List<TeamList> tfinalList = new List<TeamList>();// on créer une liste vide de teamlist
             * foreach (Team t in teams)//Pour chaque equipe de notre ennsemble d'equipe faisant partie d'un mememe et seul projet
             * {
             *  EmployeeService employeeRepo = new EmployeeService();// on demande les methodes de l'employee
             *  TeamList teamList = new TeamList(t, employeeRepo.Get(t.TeamManagerId));// on créer une team list à partir de l'equipe et de son teamManager
             *
             *  tfinalList.Add(teamList);//ajouter le teamList crée à notre liste de teamlist
             * } la boucl au dessus a été resumé en Linq sur la ligne qui suit*/
            List <TeamListItem>           tfinalList = teams.Select(team => new TeamListItem(team, repemp.Get(team.TeamManagerId))).ToList();
            IEnumerable <SubjectListItem> subjects   = repoMessage.GetProjectMessages(id).Select(m => new SubjectListItem(new Models.Message(m), new Models.Message(repoMessage.GetLastMessage(m.Id))));
            IEnumerable <DocumentList>    docs       = repoDoc.GetByProject(id).Select(d => new DocumentList(d));
            ProjectDetail proj = new ProjectDetail(project, repemp.Get(project.ProjectManager), tfinalList, taskList, subjects, docs);

            return(View(proj));
        }
        public ActionResult Details(int projectId)
        {
            C.Project            Project = ProjectService.GetProjectById(projectId);
            C.Employee           Manager = EmployeeService.Get((int)ProjectService.GetProjectManagerId(projectId));
            C.Employee           Creator = EmployeeService.Get(Project.CreatorId);
            IEnumerable <C.Team> Teams   = ProjectService.GetAllTeamsForProject(projectId);
            DetailsForm          Form    = new DetailsForm
            {
                Id          = (int)Project.Id,
                Name        = Project.Title,
                Description = Project.Description,
                Manager     = Manager,
                Creator     = Creator,
                StartDate   = Project.Start,
                EndDate     = Project.End,
                Teams       = Teams
            };

            return(View(Form));
        }
Esempio n. 3
0
        public ActionResult Details(int id)
        {
            C.Team     Team                  = TeamService.GetTeamById(id);
            C.Employee TeamLeader            = EmployeeService.Get((int)TeamService.GetTeamLeaderId(id));
            C.Employee Creator               = EmployeeService.Get(Team.Creator_Id);
            C.Project  Project               = ProjectService.GetProjectById(Team.Project_Id);
            IEnumerable <C.Employee> Members = TeamService.GetAllEmployeesForTeam(id);
            DetailsForm Form                 = new DetailsForm
            {
                Id          = (int)Team.Id,
                Name        = Team.Name,
                TeamLeader  = TeamLeader,
                Creator     = Creator,
                Project     = Project,
                DateCreated = Team.Created,
                EndDate     = Team.Disbanded,
                Members     = Members
            };

            return(View(Form));
        }
        public ActionResult Edit(int projectId)
        {
            C.Project  project = ProjectService.GetProjectById(projectId);
            C.Employee Manager = EmployeeService.Get((int)ProjectService.GetProjectManagerId(projectId));
            EditForm   form    = new EditForm()
            {
                Id                       = (int)project.Id,
                Name                     = project.Title,
                Description              = project.Description,
                ProjectManagerId         = (int)Manager.Employee_Id,
                SelectedProjectManagerId = (int)Manager.Employee_Id,
                StartDate                = project.Start,
                EndDate                  = project.End,
                CreatorId                = project.CreatorId
            };
            IEnumerable <C.Employee> Employees         = EmployeeService.GetAllActive();
            List <SelectListItem>    ManagerCandidates = new List <SelectListItem>();

            foreach (C.Employee emp in Employees)
            {
                ManagerCandidates.Add(new SelectListItem()
                {
                    Text  = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")",
                    Value = emp.Employee_Id.ToString()
                });
            }
            if (!Employees.Any(emp => emp.Employee_Id == Manager.Employee_Id))
            {
                ManagerCandidates.Add(new SelectListItem()
                {
                    Text  = "!!!VIRÉ!!! " + Manager.FirstName + " " + Manager.LastName + " (" + Manager.Email + ")",
                    Value = Manager.Employee_Id.ToString()
                });
            }
            form.ProjectManagerCandidateList = ManagerCandidates;

            return(View(form));
        }
Esempio n. 5
0
 public ProjectDetail(CD.Project project, CD.Employee emp, IEnumerable <TeamListItem> teams, IEnumerable <TaskListItem> tasks) : base(project, emp)
 {
     Tasks = (tasks != null) ? tasks.ToList() : new List <TaskListItem>();
     Teams = teams;
 }
Esempio n. 6
0
        public ActionResult Index()
        {
            int             Employee_Id = SessionUser.GetUser().Id;
            List <ListForm> list        = new List <ListForm>();

            foreach (D.Team Team in TeamService.GetAllActiveTeamsForEmployee(Employee_Id))
            {
                int?       TeamLeaderId     = TeamService.GetTeamLeaderId((int)Team.Id);
                D.Employee TeamLeader       = EmployeeService.Get((int)TeamLeaderId);
                D.Project  Project          = ProjectService.GetProjectById(Team.Project_Id);
                int?       ProjectManagerId = ProjectService.GetProjectManagerId((int)Project.Id);
                D.Employee ProjectManager   = EmployeeService.Get((int)ProjectManagerId);
                ListForm   form             = new ListForm
                {
                    TeamId          = (int)Team.Id,
                    Name            = Team.Name,
                    TeamLeader      = TeamLeader,
                    ProjectManager  = ProjectManager,
                    Project         = Project,
                    CreationDate    = Team.Created,
                    ProjectDeadLine = Project.End,
                    AmIPartOfTeam   = true
                };
                list.Add(form);
            }

            foreach (D.Team Team in TeamService.GetActiveTeamsForTeamLeader(Employee_Id))
            {
                ListForm ThisTeam = list.FirstOrDefault(f => f.TeamId == Team.Id);
                if (ThisTeam != null)
                {
                    ThisTeam.AmITeamLeader = true;
                }
                else
                {
                    D.Employee TeamLeader       = EmployeeService.Get(Employee_Id);
                    D.Project  Project          = ProjectService.GetProjectById(Team.Project_Id);
                    int?       ProjectManagerId = ProjectService.GetProjectManagerId((int)Project.Id);
                    D.Employee ProjectManager   = EmployeeService.Get((int)ProjectManagerId);
                    ListForm   form             = new ListForm
                    {
                        TeamId          = (int)Team.Id,
                        Name            = Team.Name,
                        TeamLeader      = TeamLeader,
                        ProjectManager  = ProjectManager,
                        Project         = Project,
                        CreationDate    = Team.Created,
                        ProjectDeadLine = Project.End,
                        AmITeamLeader   = true
                    };
                    list.Add(form);
                }
            }
            foreach (D.Project Project in ProjectService.GetActiveProjectsForManager(Employee_Id))
            {
                foreach (D.Team Team in ProjectService.GetAllTeamsForProject((int)Project.Id))
                {
                    ListForm ThisTeam = list.FirstOrDefault(f => f.TeamId == Team.Id);
                    if (ThisTeam != null)
                    {
                        ThisTeam.AmIProjectManager = true;
                    }
                    else
                    {
                        int?       TeamLeaderId   = TeamService.GetTeamLeaderId((int)Team.Id);
                        D.Employee TeamLeader     = EmployeeService.Get((int)TeamLeaderId);
                        D.Employee ProjectManager = EmployeeService.Get(Employee_Id);
                        ListForm   form           = new ListForm
                        {
                            TeamId            = (int)Team.Id,
                            Name              = Team.Name,
                            TeamLeader        = TeamLeader,
                            ProjectManager    = ProjectManager,
                            Project           = Project,
                            CreationDate      = Team.Created,
                            ProjectDeadLine   = Project.End,
                            AmIProjectManager = true
                        };
                        list.Add(form);
                    }
                }
            }
            return(View(list));
        }