// GET: Team/Delete/5 /*[ProjectManagerRequired]*/ public ActionResult Delete(int id) { /* try * { * // TODO: Add insert logic here * TeamService r = new TeamService(); * r.Delete(id); * return RedirectToAction("Index"); * } * catch(Exception e) * { * Debug.WriteLine(e.Message); * return RedirectToAction("Index"); * }*/ TeamService r = new TeamService(); //Je fais appel aux methdes de mon TeamService if (r.CountEmployee(id) == 0) // je controlle le nombe d'elements de ma team { EmployeeService repoEmployee = new EmployeeService(); CD.Team team = r.Get(id); CD.Employee teamManager = repoEmployee.Get(team.TeamManagerId); TeamListItem t = new TeamListItem(team, teamManager); //Je crée ma teamDetail return(View(t)); // je renvoie les details de ma vue } return(RedirectToAction("Details", new { id = id })); }
// GET: Admin/Team/Edit/5 public ActionResult Edit(int id) { C.Team Team = TeamService.GetTeamById(id); C.Employee TeamLeader = EmployeeService.Get((int)TeamService.GetTeamLeaderId(id)); EditForm form = new EditForm() { Id = (int)Team.Id, Name = Team.Name, SelectedTeamLeaderId = (int)TeamLeader.Employee_Id, CreatorId = Team.Creator_Id }; IEnumerable <C.Employee> Employees = EmployeeService.GetAllActive(); List <SelectListItem> TeamLeaderCandidates = new List <SelectListItem>(); foreach (C.Employee emp in Employees) { TeamLeaderCandidates.Add(new SelectListItem() { Text = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")", Value = emp.Employee_Id.ToString() }); } // si le TeamLeader actuel est desactivé if (!Employees.Any(emp => emp.Employee_Id == TeamLeader.Employee_Id)) { TeamLeaderCandidates.Add(new SelectListItem() { Text = "!!!VIRÉ!!! " + TeamLeader.FirstName + " " + TeamLeader.LastName + " (" + TeamLeader.Email + ")", Value = TeamLeader.Employee_Id.ToString() }); } form.TeamLeaderCandidateList = TeamLeaderCandidates; return(View(form)); }
public CurrentOn(CD.Team team) { if (team != null) { Id = team.Id; Name = team.Name; } }
// GET: Team/Edit/5 /*[ProjectManagerRequired]*/ public ActionResult Edit(int id) { TeamService r = new TeamService(); CD.Team t = r.Get(id); TeamEdit te = new TeamEdit(t); return(View(te)); }
public ListForm(C.Team Team, C.Employee TeamLeader, C.Employee Creator, C.Project Project) { TeamId = (int)Team.Id; Name = Team.Name; this.TeamLeader = TeamLeader; this.Creator = Creator; this.Project = Project; CreationDate = Team.Created; EndDate = Team.Disbanded; }
public ActionResult Edit(int id, TeamEdit collection) { TeamService r = new TeamService(); // Procure les methodes d'acces à la DB CD.Team t = new CD.Team(id, collection.Name); // Création d'une nouvelle équipe à partir du formulaire (collection) if (r.Update(t)) // r.update(): appel de la methide update pour mettre à jour la team, le if(conntrolle si la mise à jour a été faite) { return(RedirectToAction("Details", new { controller = "Team", id = id })); // nous redirige vers l'action detail, se trouvant dans le controller Team avec le parametre Id } return(View(collection)); //retourne le formulaire }
internal static G.Team ToGlobal(this C.Team team) { return(new G.Team() { Id = team.Id, Name = team.Name, //CreateDate = team.CreateDate, ProjectId = team.ProjectId, TeamManagerId = team.TeamManagerId }); }
// GET: Admin/Team/Delete/5 public ActionResult Delete(int id) { C.Team Team = TeamService.GetTeamById(id); DeleteForm form = new DeleteForm() { Team_Id = (int)Team.Id, Name = Team.Name, Created = Team.Created, Creator_Id = Team.Creator_Id, Project_Id = Team.Project_Id }; return(View(form)); }
public ActionResult Create(int id, TeamCreateForm collection) { try { // TODO: Add insert logic here TeamService r = new TeamService(); EmployeeService employeeRepo = new EmployeeService(); CD.Employee TeamManager = employeeRepo.Get().Where <CD.Employee>(emp => emp.Email == collection.TeamManagerId).SingleOrDefault(); CD.Team t = new CD.Team(collection.Name, id, TeamManager.Id); t = r.Insert(t); return(RedirectToAction("Details", new { controller = "Project", id = id })); } catch { return(View(collection)); } }
public ActionResult Create(CreateForm form) { if (ModelState.IsValid) { D.Team t = new D.Team(form.Name, SessionUser.GetUser().Id, form.SelectedProjectId); int TeamLeaderId = form.SelectedTeamLeaderId; try { int?NewTeam_Id = TeamService.Create(t, TeamLeaderId); if (NewTeam_Id != null) { return(RedirectToAction("EmployeesInTeam", new { teamId = NewTeam_Id })); } } catch (System.Data.SqlClient.SqlException exception) { throw (exception); } } IEnumerable <D.Employee> Employees = EmployeeService.GetAllActive(); List <SelectListItem> TeamLeaderCandidates = new List <SelectListItem>(); foreach (D.Employee emp in Employees) { TeamLeaderCandidates.Add(new SelectListItem() { Text = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")", Value = emp.Employee_Id.ToString() }); } form.TeamLeaderCandidateList = TeamLeaderCandidates; IEnumerable <D.Project> Projects = ProjectService.GetAllActive(); List <SelectListItem> ProjectCandidates = new List <SelectListItem>(); foreach (D.Project p in Projects) { ProjectCandidates.Add(new SelectListItem() { Text = p.Title, Value = p.Id.ToString() }); } form.ProjectCandidateList = ProjectCandidates; return(View(form)); }
public ActionResult Details(int teamId) { int Employee_Id = SessionUser.GetUser().Id; D.Team Team = TeamService.GetTeamById(teamId); D.Employee TeamLeader = EmployeeService.Get((int)TeamService.GetTeamLeaderId(teamId)); D.Employee Creator = EmployeeService.Get(Team.Creator_Id); D.Project Project = ProjectService.GetProjectById(Team.Project_Id); IEnumerable <TaskListForm> Tasks = TaskService.GetForTeam(teamId, Employee_Id).Select(task => new TaskListForm { Id = task.Id, Creator = EmployeeService.Get(task.CreatorId), Name = task.Title, Description = task.Description, StartDate = task.Start, EndDate = task.End, Deadline = task.Deadline, TaskSubtaskOf = (task.SubtaskOf != null) ? TaskService.Get((int)task.SubtaskOf, SessionUser.GetUser().Id) : null, StatusName = task.StatusName }); IEnumerable <D.Employee> Members = TeamService.GetAllEmployeesForTeam(teamId); 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, DiscScriptForm = new Models.ViewModels.Message.DiscussionScriptForm { ToTeam = Team.Id }, Tasks = Tasks, IsTeamLeader = (Employee_Id == TeamLeader.Employee_Id), IsProjectManager = (Employee_Id == ProjectService.GetProjectManagerId(Team.Project_Id)), Documents = DocumentService.GetForTeam((int)Team.Id).Select(d => new Doc.ListForm { Name = d.Filename, Id = (int)d.Id }) }; return(View(Form)); }
public ActionResult Delete(int teamId) { int Employee_Id = SessionUser.GetUser().Id; D.Team Team = TeamService.GetTeamById(teamId); if (AuthService.IsAdmin(Employee_Id) || ProjectService.GetProjectManagerId(Team.Project_Id) == Employee_Id) { DeleteForm form = new DeleteForm() { Team_Id = (int)Team.Id, Name = Team.Name, Created = Team.Created, Creator_Id = Team.Creator_Id, Project_Id = Team.Project_Id }; return(View(form)); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id, EditForm form) { if (ModelState.IsValid) { C.Team Team = new C.Team(form.Id, form.Name, form.Created, null, form.CreatorId, form.ProjectId, null); try { if (TeamService.Edit(SessionUser.GetUser().Id, Team, form.SelectedTeamLeaderId)) { return(RedirectToAction("Index")); } } catch (System.Data.SqlClient.SqlException exception) { throw (exception); } return(RedirectToAction("Edit")); } return(View(form)); }
// GET: Team/Details/5 public ActionResult Details(int id) { TeamService teamRepo = new TeamService(); CD.Team team = teamRepo.Get(id); EmployeeService employeeRepo = new EmployeeService(); DocumentService repoDoc = new DocumentService(); IEnumerable <CD.Employee> employees = employeeRepo.GetByTeamId(id); List <EmployeeListItem> finalList = new List <EmployeeListItem>(); foreach (CD.Employee employee in employees) { finalList.Add(new EmployeeListItem(employee)); } MessageService repoMessage = new MessageService(); IEnumerable <ConversationListItem> conversations = repoMessage.GetTeamMessages(id).Select(m => new ConversationListItem(new M.Message(m), new M.Message(repoMessage.GetLastMessage(m.Id)), team)); IEnumerable <DocumentList> docs = repoDoc.GetByTeam(id).Select(d => new DocumentList(d)); TeamDetail teamDetail = new TeamDetail(team, employeeRepo.Get(team.TeamManagerId), finalList, conversations, docs); return(View(teamDetail)); }
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 Delete(int teamId, DeleteForm form) { if (ModelState.IsValid) { if (teamId == form.Team_Id) { D.Team Team = new D.Team(form.Team_Id, form.Name, form.Created, null, form.Creator_Id, form.Project_Id, null); try { if (TeamService.Delete(Team, SessionUser.GetUser().Id)) { return(RedirectToAction("Index")); } } catch (System.Data.SqlClient.SqlException Exception) { throw Exception; } } } return(View(form)); }
internal static G.Team ToGlobal(this C.Team entity) { List <G.Employee> Employees = new List <G.Employee>(); if (!(entity.Employees is null)) { foreach (C.Employee Employee in entity.Employees) { Employees.Add(ToGlobal(Employee)); } } return(new G.Team { Id = entity.Id, Name = entity.Name, Created = entity.Created, Disbanded = entity.Disbanded, Creator_Id = entity.Creator_Id, Project_Id = entity.Project_Id, Employees = Employees }); }
public ActionResult EmployeesInTeam(int teamId) { int Employee_Id = SessionUser.GetUser().Id; D.Team Team = TeamService.GetTeamById(teamId); IEnumerable <D.Employee> Employees = EmployeeService.GetAllActive(); IEnumerable <D.Employee> EmployeesInTeam = TeamService.GetAllEmployeesForTeam(teamId); List <EmployeeTeamSelector> EmployeesInTeamFormList = new List <EmployeeTeamSelector>(); foreach (D.Employee employee in Employees) { IEnumerable <D.Department> departments = DepartmentService.GetEmployeeActiveDepartments((int)employee.Employee_Id); EmployeesInTeamFormList.Add(new EmployeeTeamSelector { Team = Team, Employee = employee, Departments = departments, IsInTeam = EmployeesInTeam.Any(x => x.Employee_Id == employee.Employee_Id) }); } return(View(EmployeesInTeamFormList)); }