Beispiel #1
0
        public int Create(Dato p)
        {
            int inserterd = 0;

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

            return(inserterd);
        }
Beispiel #2
0
 public IEnumerable <Persona> getAllPersonaall()
 {
     try
     {
         using (var db = new AgendaTelelefonicaContext())
         {
             return(db.Personas.ToList());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #3
0
 public IEnumerable <Dato> getAllDato()
 {
     try
     {
         using (var db = new AgendaTelelefonicaContext())
         {
             return(db.Datos.ToList());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #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;
     }
 }
Beispiel #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);
        }
Beispiel #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);
        }