summaryrefslogtreecommitdiff
path: root/src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs')
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs
new file mode 100644
index 0000000..39286d0
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using Cmpp298.Assignment3.Dto;
+using Cmpp298.Assignment3.Task;
+
+namespace Cmpp298.Assignment3.Presentation {
+ public class InvoicesMainPresenter {
+ private readonly IInvoiceTask _invoiceTask;
+ private readonly IInvoicesMainView _view;
+ private readonly IVendorTask _vendorsTask;
+
+ public InvoicesMainPresenter( IInvoicesMainView view ) : this( view, new VendorTask( ), new InvoiceTask( ) ) {}
+
+ public InvoicesMainPresenter( IInvoicesMainView view, IVendorTask vendorsTask, IInvoiceTask invoiceTask ) {
+ _view = view;
+ _vendorsTask = vendorsTask;
+ _invoiceTask = invoiceTask;
+ }
+
+ public void Initialize( ) {
+ _view.VendorNames.BindTo( _vendorsTask.GetAllVendorNames( ) );
+ }
+
+ public void LoadInvoices( ) {
+ IDropDownListItem selectedItem = _view.VendorNames.SelectedItem;
+ if ( selectedItem != null ) {
+ IEnumerable< DisplayInvoiceDto > enumerable = _invoiceTask.GetAllInvoices( selectedItem.Value );
+ _view.BindTo( enumerable );
+ }
+ }
+ }
+} \ No newline at end of file