private void OnRemoveFriendExecute() { var selectedFriendToRemove = SelectedAddedFried; var friendToRemove = Meeting.Model.FriendMeetings .FirstOrDefault(e => e.FriendId == selectedFriendToRemove.Id && e.MeetingId == Meeting.Id); Meeting.Model.FriendMeetings.Remove(friendToRemove); AddedFriends.Remove(selectedFriendToRemove); AvailibleFriends.Add(selectedFriendToRemove); HasChange = _meetingService.HasChanges(); ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); }
private void SetupPickList() { var meetingFriendIds = Meeting .Model .FriendMeetings .Select(fm => fm.Friend) .Select(f => f.Id).ToList(); var addableFriends = _allFriends .Where(f => meetingFriendIds.Contains(f.Id)) .OrderBy(f => f.FirstName); var availibleFriends = _allFriends .Except(addableFriends) .OrderBy(f => f.FirstName); AddedFriends.Clear(); AvailibleFriends.Clear(); foreach (var af in addableFriends) { AddedFriends.Add(new FriendModel() { Id = af.Id, Email = af.Email, FirstName = af.FirstName, LastName = af.LastName }); } foreach (var af in availibleFriends) { AvailibleFriends.Add(new FriendModel() { Id = af.Id, Email = af.Email, FirstName = af.FirstName, LastName = af.LastName }); } }