Beispiel #1
0
 public void DeleteFriend(Friend deleteFriend)
 {
     using (AddressBookContext dataContext = new AddressBookContext())
     {
         Friend friendToDelete = dataContext.Friends.Single(t => t.ID == deleteFriend.FirstName);
         dataContext.Friends.Remove(friendToDelete);
         dataContext.SaveChanges();
     }
 }
Beispiel #2
0
        public void UpdateFriend(Friend updatefriend)
        {
            using (AddressBookContext dataContext = new AddressBookContext())
            {
                Friend friendToUpdate = dataContext.Friends.Single(t => t.FirstName == updatefriend.FirstName);
                updatefriend.FirstName = updatefriend.FirstName;
                updatefriend.LastName = updatefriend.LastName;
                updatefriend.Street = updatefriend.Street;
                updatefriend.State = updatefriend.State;
                updatefriend.Zip = updatefriend.Zip;

                dataContext.SaveChanges();
            }
        }
Beispiel #3
0
 public void AddFriend(Friend newFriend)
 {
     using (AddressBookContext dataContext = new AddressBookContext())
     {
         Friend friend = new Friend
         {
             FirstName = newFriend.FirstName,
             LastName = newFriend.LastName,
             Street = newFriend.Street,
             State = newFriend.State,
             Zip = newFriend.Zip,
         };
         dataContext.Friends.Add(friend);
         dataContext.SaveChanges();
     }
 }