Example #1
0
 public Friend GetFriendById(int friendId)
 {
     using (var context = new FriendsOrganizerDbEntities())
     {
         return(context.Friends.FirstOrDefault(f => f.Id == friendId));
     }
 }
Example #2
0
 public List <Friend> GetFriends()
 {
     using (var context = new FriendsOrganizerDbEntities())
     {
         return(context.Friends.ToList());
     }
 }
Example #3
0
        public void Insert(Friend friend)
        {
            using (var context = new FriendsOrganizerDbEntities())
            {
                context.Friends.Add(friend);

                context.SaveChanges();
            }
        }
Example #4
0
 public void Delete(int friendId)
 {
     using (var context = new FriendsOrganizerDbEntities())
     {
         var result = context.Friends.FirstOrDefault(f => f.Id == friendId);
         context.Friends.Remove(result);
         context.SaveChanges();
     }
 }
Example #5
0
 public void Save(Friend friend)
 {
     using (var context = new FriendsOrganizerDbEntities())
     {
         var result = context.Friends.FirstOrDefault(f => f.Id == friend.Id);
         result.FirstName = friend.FirstName;
         result.LastName  = friend.LastName;
         result.Email     = friend.Email;
         context.SaveChanges();
     }
 }