Beispiel #1
0
        // add an entry to the phone book database
        public void AddEntry(string lastName, string firstName, string phoneNumber)
        {
            // create PhoneBook entry to be inserted in database
            PhoneBook entry = new PhoneBook()
            {
                FirstName   = firstName,
                LastName    = lastName,
                PhoneNumber = phoneNumber
            };

            // insert PhoneBook entry in database
            dbcontext.PhoneBooks.Add(entry);
            dbcontext.SaveChanges();
        } // end method AddEntry
        void IPhoneBookRESTXMLService.AddEntry(string firstName, string lastName, string phoneNumber)
        {
            PhoneBookEntry entry = new PhoneBookEntry();

            entry.FirstName   = firstName;
            entry.LastName    = lastName;
            entry.PhoneNumber = phoneNumber;

            using (var contxt = new PhoneBookEntities())
            {
                PhoneBook book = new PhoneBook();

                book.FirstName   = firstName;
                book.LastName    = lastName;
                book.PhoneNumber = phoneNumber;
                contxt.PhoneBooks.Add((book));
                contxt.SaveChanges();
            }
        }
        void IPhoneBookRESTXMLService.AddEntry(string firstName, string lastName, string phoneNumber)
        {
            PhoneBookEntry entry = new PhoneBookEntry();

               entry.FirstName = firstName;
               entry.LastName = lastName;
               entry.PhoneNumber = phoneNumber;

               using(var contxt = new PhoneBookEntities())
               {
               PhoneBook book = new PhoneBook();

               book.FirstName = firstName;
               book.LastName = lastName;
               book.PhoneNumber = phoneNumber;
               contxt.PhoneBooks.Add((book));
               contxt.SaveChanges();
               }
        }