Exemplo n.º 1
0
        public JsonResult EmployeesInTeam(int id, int EmployeeId, bool IsChecked)
        {
            if (IsChecked)
            {
                TeamService.AddEmployee(id, EmployeeId, SessionUser.GetUser().Id);
            }
            else
            {
                TeamService.RemoveEmployee(id, EmployeeId, SessionUser.GetUser().Id);
            }

            return(new JsonResult
            {
                Data = TeamService.IsInTeam(id, EmployeeId)
            });
        }
Exemplo n.º 2
0
        public ActionResult EmployeesInTeam(IEnumerable <EmployeeTeamSelector> forms)
        {
            bool IsInTeam;
            IEnumerable <D.Employee> EmployeesInTeam = TeamService.GetAllEmployeesForTeam((int)forms.First().Team.Id);

            foreach (EmployeeTeamSelector selector in forms)
            {
                IsInTeam = EmployeesInTeam.Any(x => x.Employee_Id == selector.Employee.Employee_Id);
                if (selector.IsInTeam && !IsInTeam)
                {
                    TeamService.AddEmployee((int)selector.Team.Id, (int)selector.Employee.Employee_Id, SessionUser.GetUser().Id);
                }
                else if (!selector.IsInTeam && IsInTeam)
                {
                    TeamService.RemoveEmployee((int)selector.Team.Id, (int)selector.Employee.Employee_Id, SessionUser.GetUser().Id);
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult DelEmployee(int id, TeamDelEmployee collection)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             EmployeeService employeeRepo = new EmployeeService();
             CD.Employee     employee     = employeeRepo.Get().Where <CD.Employee>(emp => emp.Email == collection.Email).SingleOrDefault();
             if (employee != null)
             {
                 TeamService r = new TeamService();
                 if (r.AddEmployee(employee.Id, id)) //<<----------------Merci, j'ai bien rit ;)
                 {
                     return(RedirectToAction("Details", new { id = id }));
                 }
                 else
                 {
                     return(View(collection));
                 }
             }
             else
             {
                 return(View(collection));
             }
         }
         else
         {
             return(View(collection));
         }
     }
     catch
     {
         return(View(collection));
     }
 }