using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Input; using ComplianceNFs.Core.Entities; namespace ComplianceNFs.Monitor { public class MonitorViewModel : INotifyPropertyChanged { public ObservableCollection RecentInvoices { get; } = new(); public ICommand ForceScanCommand { get; } public event PropertyChangedEventHandler PropertyChanged; public MonitorViewModel() { // TODO: Inject IInvoiceStatusStream and subscribe to updates ForceScanCommand = new RelayCommand(_ => ForceScan()); } private void ForceScan() { // TODO: Call service to force ingestion cycle } protected void OnPropertyChanged([CallerMemberName] string name = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } } public class RelayCommand : ICommand { private readonly Action _execute; private readonly Func _canExecute; public RelayCommand(Action execute, Func canExecute = null) { _execute = execute; _canExecute = canExecute; } public bool CanExecute(object parameter) => _canExecute == null || _canExecute(parameter); public void Execute(object parameter) => _execute(parameter); public event EventHandler CanExecuteChanged { add { } remove { } } } }