AR Payment Reversal Navigation Implementation
Overview
The AR Payment Reversal dashboard implements the Navigation Architecture Pattern with specific workflows optimized for financial transaction reversal processes.
Navigation Flow
MainView (Container)
├── ArReversePaymentQueueView (Default/Home)
│ ├── ArReversePaymentAddPaymentView (Add payments to queue)
│ │ └── CustomerSelectionDialogView (Modal selection)
│ └── ArReversePaymentCompletionView (Post-processing results)
└── SettingsDialogView (Configuration modal)
Implementation Details
MainViewModel Configuration
The MainViewModel serves as the navigation host with specific configurations for payment reversal:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/MainViewModel.cs (Lines 5-144)
public class MainViewModel : BaseRouteableViewModel
{
private readonly BasicMepNavigationUiHostNotificator _navigationUiHostNotificator;
public MainViewModel(...)
{
_navigationUiHostNotificator.MainContentChanged += (sender, e) => SetMainContent(sender);
this.Title = "AR Payment Reversal";
}
public void SetMainContent(object content)
{
Dispatcher.CurrentDispatcher.Invoke(() =>
{
var navigatedFromContent = mainContent;
MainContent = content;
if (navigatedFromContent is INavigationTarget)
((INavigationTarget) navigatedFromContent)?.NavigatedFrom();
if (content is INavigationTarget)
((INavigationTarget) content)?.NavigatedTo();
});
}
}
Queue-Based Navigation Pattern
The dashboard implements a queue-centric navigation pattern:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/ArReversePaymentQueueViewModel.cs (Lines 259-272)
public event EventHandler<EventArgs> NavigateToAddPayment;
private async Task AddPayment()
{
IsLoading = true;
await Task.Delay(300).ConfigureAwait(true);
NavigateToAddPayment?.Invoke(this, new EventArgs());
}
Property-Based Navigation Triggers
Navigation is triggered based on property changes specific to payment reversal workflow:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/ArReversePaymentQueueViewModel.cs (Lines 79-95)
private async void ArReversePaymentQueueViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "ReversePaymentQueueHeaders":
await ReversePaymentQueueHeadersChanged().ConfigureAwait(true);
break;
}
}
Navigation Guards
Payment Queue Validation
Navigation guards ensure data integrity before allowing transitions:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/ArReversePaymentQueueViewModel.cs (Lines 341-346)
if (ReversePaymentQueueHeaders == null || !ReversePaymentQueueHeaders.Any())
return;
IsLoading = true;
// Proceed with navigation
Thread Safety
All navigation operations are synchronized with the UI thread:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/MainViewModel.cs (Lines 84-105)
Dispatcher.CurrentDispatcher.Invoke(() =>
{
if (_logger.IsEnabled(LogLevel.Trace))
_logger.LogTrace("CHANGING MAIN CONTENT to {ContentIsNull}, {NameOfContent}",
content == null, content?.GetType().Name);
// Navigation logic here
});
Memory Management
The dashboard implements proper disposal patterns during navigation:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/MainViewModel.cs (Lines 136-144)
private bool disposed = false;
public void Dispose()
{
if (!disposed)
{
disposed = true;
// Cleanup logic
}
}
Error Handling
Comprehensive error handling for navigation failures:
// MepApps.Dash.Ar.Maint.PaymentReversal/ViewModels/MainViewModel.cs (Lines 28-33)
catch (Exception ex)
{
_logger.LogError(ex, "Failed to initialize MainViewModel");
throw;
}
Dashboard-Specific Features
1. Payment Queue Management
- Maintains navigation state across payment queue operations
- Preserves selected payments during navigation
- Handles batch processing navigation flows
2. Customer Selection Integration
- Modal dialog navigation for customer selection
- Maintains parent context during modal operations
- Returns selected customer data to calling view
3. Completion View Navigation
- Displays processing results after reversal
- Provides navigation back to queue with state reset
- Maintains audit trail during navigation
Performance Optimizations
Loading Indicators
private async Task NavigateWithLoading()
{
IsLoading = true;
await Task.Delay(300).ConfigureAwait(true); // Smooth transition
NavigateToTarget?.Invoke(this, new EventArgs());
IsLoading = false;
}
Lazy View Loading
Views are instantiated only when first accessed to improve startup performance.
Related Documentation
Summary
The AR Payment Reversal dashboard's navigation implementation extends the base MepDash navigation patterns with specific features for financial transaction workflows. The queue-centric design, combined with proper state management and error handling, ensures reliable navigation through complex payment reversal processes.