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

                context.SaveChanges();
            }
        }
Esempio n. 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();
     }
 }
Esempio n. 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();
     }
 }