public ActionResult Edit(int id) { try { C.Employee e = EmployeeService.GetForAdmin(id); if (!(e is null)) { EditForm form = new EditForm() { Id = id, LastName = e.LastName, FirstName = e.FirstName, Email = e.Email, Address = e.Address, Phone = e.Phone, RegNat = e.RegNat, IsAdmin = (bool)e.IsAdmin }; return(View(form)); } } catch (Exception exception) { throw (exception); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id, EditForm form) { if (ModelState.IsValid) { if (id == form.Id) { C.Employee e = new C.Employee(form.Id, form.LastName, form.FirstName, form.Email, form.Password, true, form.RegNat, null, form.Address, form.Phone, form.IsAdmin); try { if (EmployeeService.UpdateForAdmin(e)) { return(RedirectToAction("Index")); } } catch (System.Data.SqlClient.SqlException exeption) { if (exeption.Number == 2627) { if (exeption.Message.Contains("UC_Email")) { ModelState.AddModelError("Email", "Cet email est déjà utilisé"); } if (exeption.Message.Contains("UC_RegNat")) { ModelState.AddModelError("RegNat", "Ce numero de régistre national est déjà utilisé."); } } } } } return(View(form)); }
// 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.Employee employee) { if (employee != null) { Id = employee.Id; Name = employee.FirstName + ", " + employee.LastName; } }
public EmployeeListItem(CD.Employee emp) { Id = emp.Id; LastName = emp.LastName; FirstName = emp.FirstName; Email = emp.Email; _Gsm = emp.GSM; }
public ActionResult Details(int id) { int My_Id = SessionUser.GetUser().Id; C.Employee e = EmployeeService.GetForAdmin(id); DetailsForm Details = new DetailsForm() { Id = id, LastName = e.LastName, FirstName = e.FirstName, Email = e.Email, Address = e.Address, Phone = e.Phone, RegNat = e.RegNat, IsActif = e.Actif, IsAdmin = (bool)e.IsAdmin, IsMe = (e.Employee_Id == My_Id), Teams = TeamService.GetAllActiveTeamsForEmployee(id), Departments = DepartmentService.GetEmployeeActiveDepartments(id), TeamLeaderTeams = TeamService.GetActiveTeamsForTeamLeader(id), ProjectManagerProjects = ProjectService.GetActiveProjectsForManager(id), HeadOfDepartmentDepartments = DepartmentService.GetHeadOfDepartmentActiveDepartments(id), DiscScriptForm = new Models.ViewModels.Message.DiscussionScriptForm { ToEmployee = id, MyId = My_Id } }; IEnumerable <C.Department> MyDepartments = new List <C.Department>(); if (AuthService.IsAdmin(My_Id)) { MyDepartments = DepartmentService.GetAllActive(); } else { MyDepartments = DepartmentService.GetHeadOfDepartmentActiveDepartments(My_Id); } IEnumerable <C.Department> EmpDepartments = DepartmentService.GetEmployeeDepartments(id); var intersec = from MyDep in MyDepartments join EmpDep in EmpDepartments on MyDep.Id equals EmpDep.Id select new { }; if (intersec.Any()) { Details.CanIRemoveFromDepartment = true; } if (MyDepartments.Except(EmpDepartments, new DepartmentComparator()).Any()) { Details.CanIAddToDepartment = true; } return(View(Details)); }
public ActionResult Delete(int projectId) { C.Project Project = ProjectService.GetProjectById(projectId); C.Employee Manager = EmployeeService.Get((int)ProjectService.GetProjectManagerId(projectId)); C.Employee Creator = EmployeeService.Get(Project.CreatorId); DeleteForm Form = new DeleteForm(Project, Manager, Creator); return(View(Form)); }
public ActionResult Details(int projectId) { int Employee_Id = SessionUser.GetUser().Id; C.Project Project = ProjectService.GetProjectById(projectId); C.Employee Manager = EmployeeService.Get(Project.ProjectManagerId); C.Employee Creator = EmployeeService.Get(Project.CreatorId); IEnumerable <C.Team> Teams = ProjectService.GetAllTeamsForProject(projectId); IEnumerable <C.Task> Tasks = TaskService.GetForProject(projectId, Employee_Id); List <TaskForm> TasksForm = new List <TaskForm>(); foreach (C.Task Task in Tasks) { TasksForm.Add(new TaskForm { Id = Task.Id, ProjectId = Task.ProjectId, CreatorId = Task.CreatorId, Name = Task.Title, Description = Task.Description, StartDate = Task.Start, EndDate = Task.End, Deadline = Task.Deadline, SubtaskOf = Task.SubtaskOf, StatusName = Task.StatusName, StatusDate = Task.StatusDate, StatusId = Task.StatusId, TeamId = Task.TeamId, Creator = EmployeeService.Get(Task.CreatorId), TaskSubtaskOf = (Task.SubtaskOf != null) ? TaskService.Get((int)Task.SubtaskOf, SessionUser.GetUser().Id) : null, Team = (Task.TeamId != null) ? TeamService.GetTeamById((int)Task.TeamId) : null }); } 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, Tasks = TasksForm, IsProjectManager = (Employee_Id == Manager.Employee_Id), DiscScriptForm = new Models.ViewModels.Message.DiscussionScriptForm { ToProject = Project.Id }, Documents = DocumentService.GetForProject((int)Project.Id).Select(d => new Doc.ListForm { Name = d.Filename, Id = (int)d.Id }) }; return(View(Form)); }
public DeleteForm(D.Project Project, D.Employee ProjectManager, D.Employee Creator) { ProjectId = (int)Project.Id; Name = Project.Title; Description = Project.Description; StartDate = Project.Start; EndDate = Project.End; this.ProjectManager = ProjectManager; this.Creator = Creator; }
public ListForm(C.Project Project, C.Employee Manager, C.Employee Creator) { ProjectId = (int)Project.Id; Name = Project.Title; Description = Project.Description; this.Manager = Manager; this.Creator = Creator; this.StartDate = Project.Start; this.EndDate = Project.End; }
public ListForm(D.Project Project, D.Employee Manager, int MyId) { ProjectId = (int)Project.Id; Name = Project.Title; Description = Project.Description; this.Manager = Manager; this.StartDate = Project.Start; this.EndDate = Project.End; IsProjectManager = (MyId == Manager.Employee_Id); }
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; }
// GET: Admin/Department/Edit/5 public ActionResult Edit(int id) { C.Department Department = DepartmentService.GetDepartmentById(id); EditForm form = new EditForm { Id = (int)Department.Id, Title = Department.Title, Created = Department.Created, Description = Department.Description, Admin_Id = Department.Admin_Id, Admin = null, Active = Department.Active, }; IEnumerable <C.Employee> Employees = EmployeeService.GetAllActive(); List <SelectListItem> HeadOfDepartmentCandidates = new List <SelectListItem>(); foreach (C.Employee emp in Employees) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")", Value = emp.Employee_Id.ToString() }); } int?HeadOfDepId = DepartmentService.GetHeadOfDepartmentId(id); if (HeadOfDepId == null) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = "!!!NOT CHOSEN!!!", Value = 0.ToString() }); form.SelectedHeadOfDepartmentId = 0; } else { C.Employee HeadOfDepartment = EmployeeService.Get((int)HeadOfDepId); if (!Employees.Any(emp => emp.Employee_Id == HeadOfDepartment.Employee_Id)) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = "!!!VIRÉ!!! " + HeadOfDepartment.FirstName + " " + HeadOfDepartment.LastName + " (" + HeadOfDepartment.Email + ")", Value = HeadOfDepartment.Employee_Id.ToString() }); } form.SelectedHeadOfDepartmentId = (int)HeadOfDepartment.Employee_Id; } form.HeadOfDepartmentCandidateList = HeadOfDepartmentCandidates; return(View(form)); }
public ActionResult ConfirmDeleteEmployee(int teamId, int employeeId) { EmployeeService employeeRepo = new EmployeeService(); CD.Employee employees = employeeRepo.Get(employeeId); ProfilDetail pepito = new ProfilDetail(employees); return(View(pepito)); }
public ActionResult Index() { List <ListForm> list = new List <ListForm>(); foreach (C.Project Project in ProjectService.GetAllActive()) { int? ManagerId = Project.ProjectManagerId; C.Employee Manager = EmployeeService.Get((int)ManagerId); C.Employee Creator = EmployeeService.Get(Project.CreatorId); ListForm form = new ListForm(Project, Manager, Creator); list.Add(form); } return(View(list)); }
public ActionResult Index() { int Employee_Id = SessionUser.GetUser().Id; List <ListForm> list = new List <ListForm>(); foreach (C.Project Project in ProjectService.GetAllActive()) { int ManagerId = Project.ProjectManagerId; C.Employee Manager = EmployeeService.Get(ManagerId); ListForm form = new ListForm(Project, Manager, Employee_Id); list.Add(form); } return(View(list)); }
public ActionResult Delete(int id) { C.Employee emp = EmployeeService.Get(id); ListForm e = new ListForm() { LastName = emp.LastName, FirstName = emp.FirstName, Email = emp.Email, Address = emp.Address, Phone = emp.Phone, RegNat = emp.RegNat }; return(View(e)); }
// GET: Admin/Team public ActionResult Index() { List <ListForm> list = new List <ListForm>(); foreach (C.Team Team in TeamService.GetAllActive()) { int? TeamLeaderId = TeamService.GetTeamLeaderId((int)Team.Id); C.Employee TeamLeader = EmployeeService.Get((int)TeamLeaderId); C.Employee Creator = EmployeeService.Get(Team.Creator_Id); C.Project Project = ProjectService.GetProjectById(Team.Project_Id); ListForm form = new ListForm(Team, TeamLeader, Creator, Project); list.Add(form); } return(View(list)); }
public EmployeeModel(CD.Employee emp) { Id = emp.Id; LastName = emp.LastName; FirstName = emp.FirstName; Email = emp.Email; Password = emp.Password; RegNat = emp.RegNat; GSM = emp.GSM; Avatar = emp.Avatar; BirthDate = emp.BirthDate; HireDate = emp.HireDate; Address = new AddressObject(emp); CoordGPS = emp.CoordGps; }
internal static G.Employee ToGlobal(this C.Employee entity) { return(new G.Employee() { Employee_Id = entity.Employee_Id, LastName = entity.LastName, FirstName = entity.FirstName, Email = entity.Email, Passwd = entity.Passwd, RegNat = entity.RegNat, Address = entity.Address, Phone = entity.Phone, IsAdmin = entity.IsAdmin }); }
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 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 Edit(int id, EmployeeEditForm collection) { try { if (ModelState.IsValid) { EmployeeService repoEmployee = new EmployeeService(); if (collection.CurrentDepartmentId != Int32.Parse(collection.SelectedItem)) { repoEmployee.AddToDepartment(id, Int32.Parse(collection.SelectedItem)); } AdminService repoAdmin = new AdminService(); bool isAdmin = repoAdmin.IsAdminByEmployeeId(id); if (collection.IsAdmin != isAdmin) { if (isAdmin) { repoAdmin.Delete(id); } else { repoAdmin.Insert(id); } } C.Employee emp = repoEmployee.Get(collection.Id); emp.Id = collection.Id; emp.FirstName = collection.FirstName; emp.LastName = collection.LastName; emp.Email = collection.Email; if (!repoEmployee.Update(emp)) { return(View(collection)); } return(RedirectToAction("Index")); } return(View(collection)); } catch { return(View(collection)); } }
public EmployeeEditForm(C.Employee employee, C.Department currentDepartment, IEnumerable <C.Department> departmentList, bool isAdmin) { Id = employee.Id; FirstName = employee.FirstName; LastName = employee.LastName; Email = employee.Email; CurrentDepartmentId = currentDepartment != null ?currentDepartment.Id: 0; List <SelectListItem> listItems = new List <SelectListItem>(); foreach (C.Department department in departmentList) { listItems.Add(new SelectListItem { Value = department.Id.ToString(), Text = department.Name }); } DepartmentList = new SelectList(listItems, "Value", "Text"); SelectedItem = CurrentDepartmentId.ToString(); IsAdmin = isAdmin; }
public ActionResult Details(int id) { C.Employee e = EmployeeService.GetForAdmin(id); DetailsForm Details = new DetailsForm() { Id = (int)e.Employee_Id, LastName = e.LastName, FirstName = e.FirstName, Email = e.Email, Address = e.Address, Phone = e.Phone, RegNat = e.RegNat, IsActif = e.Actif, IsAdmin = (bool)e.IsAdmin }; Details.DepartmentHistory = DepartmentService.GetEmployeeDepartmentHistory(id).Select(tmp => new DepartmentForm() { Id = (int)tmp.Id, StartDate = tmp.StartDate, EndDate = tmp.EndDate, Name = tmp.Name, EmpId = id, DepId = tmp.DepId, }); Details.StatusHistory = EmployeeService.GetStatusHistory(id) .Select(tmp => new StatusForm() { StatusName = tmp.Name, StartDate = tmp.StartDate, EndDate = tmp.EndDate }); Details.ProjectManagerHistory = EmployeeService.GetProjectManagerHistory(id) .Select(tmp => new ProjectManagerStatusForm() { Project_Id = tmp.Project_Id, ProjectName = tmp.Project_Name, StartDate = tmp.StartDate, EndDate = tmp.EndDate }); return(View(Details)); }
public ActionResult Edit(EditForm form) { if (ModelState.IsValid) { C.Project Project = new C.Project(form.Id, form.Name, form.Description, form.StartDate, form.EndDate, form.CreatorId, form.SelectedProjectManagerId); try { if (ProjectService.Edit(SessionUser.GetUser().Id, Project)) { return(RedirectToAction("Index")); } } catch (System.Data.SqlClient.SqlException exception) { throw (exception); } return(RedirectToAction("Edit")); } C.Employee Manager = EmployeeService.Get((int)ProjectService.GetProjectManagerId(form.Id)); 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)); }
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)); }
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)); }
// GET: Admin/Employee/Edit/5 public ActionResult Edit(int id) { EmployeeService repoEmp = new EmployeeService(); AdminService repoAdmin = new AdminService(); DepartmentService repoDepart = new DepartmentService(); C.Employee employee = repoEmp.Get(id);/* * C.Admin a = null; * if (repoAdmin.IsAdminByEmployeeId(id)) * { * a = repoAdmin.GetByEmployeeId(id); * } * else * { * a = new C.Admin(, e); * }*/ C.Department currentDepart = repoDepart.GetByEmployeeId(employee.Id); IEnumerable <C.Department> departmentList = repoDepart.Get(); EmployeeEditForm profil = new EmployeeEditForm(employee, currentDepart, departmentList, repoAdmin.IsAdminByEmployeeId(id)); return(View(profil)); }