Esempio n. 1
0
 public static void EditarPersona(Persona p1)
 {
     using (PruEntities1 db = new PruEntities1())
     {
         db.Entry(p1).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 2
0
 public static void AgregarPersona(Persona p1)
 {
     using (PruEntities1 db = new PruEntities1())
     {
         db.Persona.Add(p1);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public static void EliminarPersona(int id)
 {
     using (PruEntities1 db = new PruEntities1())
     {
         db.Persona.Remove(db.Persona.Where(i => i.Id == id).First());
         db.SaveChanges();
     }
 }
Esempio n. 4
0
        public static List <Persona> ObtenerPersonas()
        {
            List <Persona> perso = new List <Persona>();

            using (PruEntities1 bd = new PruEntities1())
            {
                perso = (from n in bd.Persona
                         select n).ToList();
            }

            return(perso);
        }
Esempio n. 5
0
        public static Persona ObtenerPorId(int id)
        {
            Persona p1 = new Persona();

            using (PruEntities1 db = new PruEntities1())
            {
                List <Persona> per = db.Persona.ToList();
                foreach (var p in per)
                {
                    if (p.Id == id)
                    {
                        p1 = p;
                    }
                }


                //return (from n in db.Persona
                //        where n.Id == id
                //        select n).First();
                //return db.Persona.Where(item => item.Id == id).First();
            }
            return(p1);
        }