Пример #1
0
        public int Create(Dato p)
        {
            int inserterd = 0;

            using (var db = new AgendaTelelefonicaContext())
            {
                db.Add(p);
                inserterd = db.SaveChanges();
            }

            return(inserterd);
        }
Пример #2
0
 public IEnumerable <Persona> getAllPersonaall()
 {
     try
     {
         using (var db = new AgendaTelelefonicaContext())
         {
             return(db.Personas.ToList());
         }
     }
     catch
     {
         throw;
     }
 }
Пример #3
0
 public IEnumerable <Dato> getAllDato()
 {
     try
     {
         using (var db = new AgendaTelelefonicaContext())
         {
             return(db.Datos.ToList());
         }
     }
     catch
     {
         throw;
     }
 }
Пример #4
0
 public IEnumerable <Persona> getAllPersona(string Nombre)
 {
     try
     {
         using (var db = new AgendaTelelefonicaContext())
         {
             return(db.Personas.Where(x => x.Nombre.Contains(Nombre)).ToList());
         }
     }
     catch
     {
         throw;
     }
 }
Пример #5
0
        public int DelelteDatobyId(int IdDatos)
        {
            int deleted = 0;

            using (var db = new AgendaTelelefonicaContext())
            {
                Dato customer = new Dato()
                {
                    IdDatos = IdDatos
                };
                db.Datos.Attach(customer);
                db.Datos.Remove(customer);
                deleted = db.SaveChanges();
            }

            return(deleted);
        }
Пример #6
0
        public int DeleltePersonabyId(int IdNombre)
        {
            int deleted = 0;

            using (var db = new AgendaTelelefonicaContext())
            {
                Persona customer = new Persona()
                {
                    IdNombre = IdNombre
                };
                db.Personas.Attach(customer);
                db.Personas.Remove(customer);
                deleted = db.SaveChanges();
            }

            return(deleted);
        }