public override int InsertFriend(Friend friend)
        {
            var context = new FriendsEntities();
            var obj = new tblFriends_Friends();
            context.AddTotblFriends_Friends(obj);
            friend.CopyToObject(obj);

            if (friend.Groups != null)
            {
                foreach (var group in friend.Groups)
                {
                    var item = new tblFriends_Groups {Id = group.Id};
                    context.AttachTo("tblFriends_Groups", item);
                    obj.Groups.Add(item);
                }
            }

            context.SaveChanges();
            return obj.Id;
        }
 public override int InsertGroup(Group group)
 {
     var context = new FriendsEntities();
     var obj = new tblFriends_Groups();
     group.CopyToObject(obj);
     context.AddTotblFriends_Groups(obj);
     context.SaveChanges();
     return obj.Id;
 }
 private static Group Convert(tblFriends_Groups obj)
 {
     if (obj == null)
     {
         return null;
     }
     var group = new Group(obj.Id, obj.CreatedDate, obj.CreatedBy, obj.ModifiedDate, obj.ModifiedBy);
     group.CopyFromObject(obj);
     return group;
 }
 public override void UpdateGroup(Group group)
 {
     var context = new FriendsEntities();
     var obj = new tblFriends_Groups {Id = group.Id};
     context.AttachTo("tblFriends_Groups", obj);
     group.CopyToObject(obj);
     context.SaveChanges();
 }