示例#1
0
        public async Task <int> Delete_Parametres(int IDParametreServicePrograme)
        {
            var obj = new db.Parametres_ServicePrograme();

            obj = await _context.Parametres_ServicePrograme.FirstOrDefaultAsync(x => x.IDParametreServicePrograme == IDParametreServicePrograme);

            if (obj != null)
            {
                _context.Parametres_ServicePrograme.Remove(obj);
                _context.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
示例#2
0
        // Insert, update Parametres_ServicePrograme
        public async Task <int> InsertUpdate_Parametres(int IDParametreServicePrograme, int IDListeService, string Temps, string Titres, string Contenu)
        {
            var obj_Parametres = new db.Parametres_ServicePrograme();

            try
            {
                var idParametreServicePrograme = IDParametreServicePrograme;
                //If idParametreServicePrograme > 0 ? Update : Insert
                if (idParametreServicePrograme > 0)
                {
                    obj_Parametres = await _context.Parametres_ServicePrograme.FirstOrDefaultAsync(x => x.IDParametreServicePrograme == idParametreServicePrograme);

                    obj_Parametres.IDListeService = IDListeService;
                    obj_Parametres.Temps          = Temps;
                    obj_Parametres.Titres         = Titres;
                    obj_Parametres.Contenu        = Contenu;

                    _context.SaveChanges();
                    return(1);
                }
                else
                {
                    obj_Parametres.IDListeService = IDListeService;
                    obj_Parametres.Temps          = Temps;
                    obj_Parametres.Titres         = Titres;
                    obj_Parametres.Contenu        = Contenu;

                    _context.Parametres_ServicePrograme.Add(obj_Parametres);
                    _context.SaveChanges();
                    return(1);
                }
            }
            catch (System.Exception)
            {
                return(0);
            }
        }