Example #1
0
        public void Delete(int id, string user = "")
        {
            Employe    emp = this.Get(id);
            List <int> ids = new List <int>();

            foreach (AffectationService affec in emp.affectationServices)
            {
                ids.Add(affec.id);
            }

            foreach (int i in ids)
            {
                _affectationServiceService.Delete(i);
            }

            _adresseService.Delete(emp.adresse.id);

            _employeRepository.Delete(x => x.id == id);

            _applicationTraceService.create(new ApplicationTrace
            {
                utilisateur = user,
                action      = Parametres.Action.Suppression.ToString(),
                description = String.Format("Supression de l'employé employe_id = {0}", id),
            });
        }
        public IActionResult OnPost()
        {
            Employe deletedEmploe = _employeRepository.Delete(Employee.Id);

            if (deletedEmploe.PhotoPath != null)
            {
                string FilePath = Path.Combine(_webHostEnviroment.WebRootPath, "images", deletedEmploe.PhotoPath);

                if (deletedEmploe.PhotoPath != "noimage.png")
                {
                    System.IO.File.Delete(FilePath);
                }
            }


            if (deletedEmploe == null)
            {
                return(RedirectToPage("NotFound"));
            }


            return(RedirectToPage("Employes"));
        }
Example #3
0
 public IActionResult Delete(int Id)
 {
     _empRepository.Delete(Id);
     return(RedirectToAction("Index"));
 }
Example #4
0
 public void Delete(long id) => _employeRepository.Delete(_employeRepository.Get(id));
 public void Delete(int id)
 {
     _repos.Delete(id);
 }