Exemple #1
0
 public void deletePerson(PersonModel personToDelete)
 {
     using (var db = new PersonContext())
     {
         db.allPersons.Attach(personToDelete);
         db.allPersons.Remove(personToDelete);
         db.SaveChanges();
     }
 }
Exemple #2
0
        public PersonModel addPerson(PersonModel personToAdd)
        {
            using (var db = new PersonContext())
            {
                db.allPersons.Add(personToAdd);
                db.SaveChanges();
            }

            syncData();
            return(personToAdd);
        }
Exemple #3
0
        public PersonModel addPerson(PersonModel personToAdd)
        {
            using (var db = new PersonContext())
            {

                db.allPersons.Add(personToAdd);
                db.SaveChanges();
            }

            syncData();
            return personToAdd;
        }
Exemple #4
0
        public void updatePerson(PersonModel personToUpdate)
        {
            using (var db = new PersonContext())
            {
                var p = (from person in db.allPersons
                         where person.Id == personToUpdate.Id
                         select person);

                foreach (var pr in p)
                {
                    pr.FirstName  = personToUpdate.FirstName;
                    pr.SecondName = personToUpdate.SecondName;
                    pr.Age        = personToUpdate.Age;
                    pr.TelNumber  = personToUpdate.TelNumber;
                }

                db.SaveChanges();
            }
        }
Exemple #5
0
        public void updatePerson(PersonModel personToUpdate)
        {
            using (var db = new PersonContext())
            {
                var p = (from person in db.allPersons
                              where person.Id == personToUpdate.Id
                              select person);

                foreach (var pr in p)
                {

                    pr.FirstName = personToUpdate.FirstName;
                    pr.SecondName = personToUpdate.SecondName;
                    pr.Age = personToUpdate.Age;
                    pr.TelNumber = personToUpdate.TelNumber;
                }

                db.SaveChanges();
            }
        }