Ejemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     db = new addressbookEntities();
     db.Contacts.Load();
     dataGridView1.DataSource = db.Contacts.Local.ToBindingList();
 }
Ejemplo n.º 2
0
        public void DeleteContact(ContactDTO wc)
        {
            db = new addressbookEntities();
            Contact contact = db.Contacts.Find(wc.Id);

            db.Contacts.Remove(contact);
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void UpdateContact(ContactDTO wc)
        {
            db = new addressbookEntities();
            Contact contact = (from x in db.Contacts where x.Id == wc.Id select x).First();

            contact.FullName    = wc.FullName;
            contact.BirthDate   = wc.BirthDate;
            contact.Description = wc.Description;
            contact.email       = wc.email;
            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public void InsertContact(ContactDTO wc)
        {
            Contact contact = new Contact();

            contact.FullName    = wc.FullName;
            contact.BirthDate   = wc.BirthDate;
            contact.Description = wc.Description;
            contact.email       = wc.email;
            db = new addressbookEntities();
            db.Contacts.Add(contact);
            db.SaveChanges();
        }
Ejemplo n.º 5
0
        public IEnumerable <ContactDTO> GetContacts()
        {
            db = new addressbookEntities();
            var contactList    = db.Contacts.ToList();
            var webContactList = new List <ContactDTO>();

            foreach (Contact contact in contactList)
            {
                ContactDTO cd = new ContactDTO();
                cd.Id          = contact.Id;
                cd.FullName    = contact.FullName;
                cd.BirthDate   = contact.BirthDate;
                cd.Description = contact.Description;
                cd.email       = contact.email;
                webContactList.Add(cd);
            }
            return(webContactList);
        }