Esempio n. 1
0
        //On first initialising the app gets all contacts from EF6 context...
        public List <Contact> GetAllContacts()
        {
            try
            {
                using (ContactMiidbEntities contactMiidbEntities = new ContactMiidbEntities())
                {
                    var c_AllContacts = contactMiidbEntities.Contacts.ToList();

                    var p_AllContacts = c_AllContacts;

                    return(p_AllContacts);
                }
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }
Esempio n. 2
0
 //Save contact to the database.
 public void Save(Contact contact)
 {
     try
     {
         using (ContactMiidbEntities contactMiidbEntities = new ContactMiidbEntities())
         {
             contactMiidbEntities.Contacts.Add(contact);
             contactMiidbEntities.SaveChanges();
         }
     }
     catch (SqlException sqlex)
     {
         throw sqlex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         MessageBox.Show("Added Succesfully!");
         //GetAllContacts();
     }
 }