private void AddActivityCommandExecuted() { RaisePropertyChanged("DisableParentWindow"); var window = new AddActivityView(_allEnquiries, null); window.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (window.DialogResult != null && window.DialogResult == true) { _allActivities.Add(window.ViewModel.Activity); Activities = new ObservableCollection <ActivityModel>(_allActivities); if (window.ViewModel.Activity.HasFollowUp) { FollowUps.Add(window.ViewModel.Activity.FollowUp); } var enquiry = _allEnquiries.First(x => x.Enquiry.ID == window.ViewModel.Activity.Activity.EnquiryID); enquiry.Activities.Add(window.ViewModel.Activity); } }
private void EditEnquiryCommandExecute(EnquiryModel item) { RaisePropertyChanged("DisableParentWindow"); var currentEnquiry = item.Clone(); item.Refresh(); var window = new NewEnquiryView(item); window.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (window.DialogResult == null || window.DialogResult != true) { item.Refresh(); return; } item.Refresh(); var viewModel = window.DataContext as NewEnquiryViewModel; bool activityChanged = viewModel.ActivityChanged; bool followUpsChanged = viewModel.FoolowUpsChanged; // var diff = LoggingService.FindDifference(currentEnquiry, item, out activityChanged, out followUpsChanged); // ProcessUpdates(item, diff); if (activityChanged) { _allActivities.RemoveAll(x => x.Activity.EnquiryID == item.Enquiry.ID); foreach (var activity in window.ViewModel.Enquiry.Activities) { _allActivities.Add(activity); } Activities = new ObservableCollection <ActivityModel>(_allActivities); } else { Activities.ForEach(x => x.Refresh()); } if (followUpsChanged) { _allFollowUps.RemoveAll( x => x.FollowUp.EnquiryID != null && (Guid)x.FollowUp.EnquiryID == item.Enquiry.ID); _allFollowUps.RemoveAll(x => x.TakenByUser == null); foreach (var followUp in window.ViewModel.Enquiry.FollowUps) { SetFollowUpPriority(followUp); _allFollowUps.Add(followUp); } FollowUps = new ObservableCollection <FollowUpModel>(_allFollowUps); } else { FollowUps.ForEach(x => x.Refresh()); } }