Esempio n. 1
0
        public IActionResult DeleteTraceSelonId(int id)
        {
            var    trace     = _maBd.Trace.FirstOrDefault(t => t.TracId == id);
            string CheminApp = "/home/ubuntu/EPM/implantation-a17-epm/SqueletteImplantation/wwwroot/Upload/";

            if (trace == null)
            {
                return(NotFound());
            }

            try
            {
                FileInfo Fichier = new FileInfo(CheminApp + trace.TraceNom);
                Fichier.Delete();
            }
            catch (IOException)
            {
                return(new BadRequestResult());
            }

            _maBd.Remove(trace);
            _maBd.SaveChanges();

            return(new OkResult());
        }
Esempio n. 2
0
        public IActionResult DeleteCritereSelonId(int id)
        {
            var critere = _maBd.Critere.FirstOrDefault(c => c.CritId == id);

            if (critere == null)
            {
                return(NotFound());
            }

            _maBd.Remove(critere);
            _maBd.SaveChanges();

            return(new OkResult());
        }
Esempio n. 3
0
        public IActionResult DeleteCategorieSelonId(int id)
        {
            var categorie = _maBd.Categorie.FirstOrDefault(ca => ca.CatId == id);

            if (categorie == null)
            {
                return(NotFound());
            }

            _maBd.Remove(categorie);
            _maBd.SaveChanges();

            return(new OkResult());
        }
Esempio n. 4
0
        public IActionResult DeleteUtilSelonId(int id)
        {
            var utilisateur = _maBd.Utilisateur.FirstOrDefault(ca => ca.UtilId == id);

            if (utilisateur == null)
            {
                return(NotFound());
            }

            _maBd.Remove(utilisateur);
            _maBd.SaveChanges();

            return(new OkResult());
        }
Esempio n. 5
0
        private void SupprEntreesUserSiPlusDe5(int IdUser)
        {
            var Entrees = from hist in _maBd.RelTracUsager
                          where IdUser == hist.UtilId
                          orderby hist.DateTelechargement
                          select hist;

            if (Entrees.Count() > 5)
            {
                var ListeTelechargementUser = Entrees.ToList();

                for (int i = 0; i < Entrees.Count() - 5; i++)
                {
                    _maBd.Remove(ListeTelechargementUser[i]);
                    _maBd.SaveChanges();
                }
            }
        }