public ActionResult Edit([Bind(Include = "IdEmploye,Matricule,NomComplet,DateEmbauche,IdPoste,IdDepartement,Actif,Ville,Email,Telephone")] Employe employe)
 {
     if (ModelState.IsValid)
     {
         var employeRepository = new EmployeRepository();
         employeRepository.UpdateEmploye(employe);
         return(RedirectToAction("Index"));
     }
     ViewBag.IdDepartement = new SelectList(db.Departement, "IdDepartement", "NomDepartement", employe.IdDepartement);
     ViewBag.IdPoste       = new SelectList(db.Poste, "IdPoste", "NomPoste", employe.IdPoste);
     return(View(employe));
 }
Пример #2
0
        public void UpdateEmploye(EmployeDto empDto, EmployeSalaireDto empSalReg, EmployeSalaireDto empSalSpe,
                                  IEnumerable <CongeDto> congesDto, IEnumerable <EmployePrelevementDto> empPrelReg,
                                  IEnumerable <EmployePrelevementDto> empPrelSpe)
        {
            //Ajouter les dates d'embauche et de naissance de l'employé à partir des champs string correspondant
            empDto.DateEmbauche  = DateTime.Parse(empDto.DateEmbaucheString);
            empDto.DateNaissance = DateTime.Parse(empDto.DateNaissanceString);

            //Déterminer si le type de l'employé
            bool isSpecial = false;

            if (empDto.TypeEmployeID == (int)LookupEnum.TypeEmploye.Special)
            {
                isSpecial = true;
            }

            //Ajouter les salaires régulier et spécial dans une liste
            List <EmployeSalaireDto> empSalaires = new List <EmployeSalaireDto>();

            empSalaires.Add(empSalReg);
            if (isSpecial)
            {
                empSalaires.Add(empSalSpe);
            }

            //Fusionner les listes de prélèvement des salaires réguliers et spéciaux s'il ya lieu
            List <EmployePrelevementDto> empPrelList = empPrelReg.ToList();

            if (isSpecial)
            {
                empPrelList.AddRange(empPrelSpe);
            }

            //Ajouter l'employé
            EmployeRepository empRep = new EmployeRepository();

            empRep.UpdateEmploye(empDto, empSalaires, congesDto, empPrelList);
        }