Пример #1
0
        private void OnRemoveFriendExecute()
        {
            var friendToRemove = SelectedAddedFriend;

            Meeting.Model.Friends.Remove(friendToRemove);
            AddedFriends.Remove(friendToRemove);
            AvailableFriends.Add(friendToRemove);
            HasChanges = _meetingRepository.HasChanges();
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
        }
        private void OnRemoveFriendExecute()
        {
            var friendToRemove = SelectedAddedFriend;

            //todo:fix the navigation
            var friendMeeting = friendToRemove.FriendMeetings
                                .Single(m => m.FriendId == friendToRemove.Id &&
                                        m.MeetingId == Meeting.Model.Id);

            Meeting.Model.FriendMeetings.Remove(friendMeeting);

            AddedFriends.Remove(friendToRemove);
            AvailableFriends.Add(friendToRemove);
            HasChanges = _meetingRepository.HasChanges();
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
        }
        private void SetupPicklist()
        {
            var meetingFriendIds = Meeting.Model.Friends.Select(f => f.Id).ToList();
            var addedFriends     = _allFriends.Where(f => meetingFriendIds.Contains(f.Id)).OrderBy(f => f.FirstName);
            var availableFriends = _allFriends.Except(addedFriends).OrderBy(f => f.FirstName);

            AddedFriends.Clear();
            AvailableFriends.Clear();
            foreach (var addedFriend in addedFriends)
            {
                AddedFriends.Add(addedFriend);
            }
            foreach (var availableFriend in availableFriends)
            {
                AvailableFriends.Add(availableFriend);
            }
        }
        private void OnAddFriendExecute()
        {
            var friendToAdd = SelectedAvailableFriend;

            //todo:fix the navigation
            Meeting.Model.FriendMeetings.Add(new FriendMeetings
            {
                Friend    = friendToAdd,
                FriendId  = friendToAdd.Id,
                Meeting   = Meeting.Model,
                MeetingId = Meeting.Model.Id
            });

            AddedFriends.Add(friendToAdd);
            AvailableFriends.Remove(friendToAdd);
            HasChanges = _meetingRepository.HasChanges();
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
        }