Esempio n. 1
0
 public static void AddContact(string fName, string lName, int phon, string mail)
 {
     using (var db = new ContactDbContext())
     {
         var contact = new Contact
         {
             FirstName = fName,
             LastName  = lName,
             Phone     = phon,
             Mail      = mail
         };
         db.Contacts.Add(contact);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
        public static void EditContact(int id, string fName, string lName, int phon, string mail)
        {
            using (var db = new ContactDbContext())
            {
                int counter = 1;

                foreach (var contact in db.Contacts)
                {
                    if (counter == id)
                    {
                        contact.FirstName = fName;
                        contact.LastName  = lName;
                        contact.Phone     = phon;
                        contact.Mail      = mail;

                        break;
                    }
                    ++counter;
                }
                db.SaveChanges();
            }
        }