예제 #1
0
        public void DeleteContact(ContactDTO wc)
        {
            db = new addressbookEntities();
            Contact contact = db.Contacts.Find(wc.Id);

            db.Contacts.Remove(contact);
            db.SaveChanges();
        }
예제 #2
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();
        }
예제 #3
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();
        }
예제 #4
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);
        }