summaryrefslogtreecommitdiff
path: root/src/app/Cmpp298.Assignment3.Desktop.Presentation/DeleteInvoicePresenter.cs
blob: 4912e30ef2ca5eac15e6e16ea68ddcac1f7ce160 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Cmpp298.Assignment3.Dto;
using Cmpp298.Assignment3.Task;

namespace Cmpp298.Assignment3.Presentation {
	public class DeleteInvoicePresenter {
		private readonly string _invoiceId;
		private readonly IDeleteInvoiceView _view;
		private readonly IInvoiceTask _invoiceTask;

		public DeleteInvoicePresenter( string invoiceId, IDeleteInvoiceView view )
			: this( invoiceId, view, new InvoiceTask( ) ) {}

		public DeleteInvoicePresenter( string invoiceId, IDeleteInvoiceView view, IInvoiceTask invoiceTask ) {
			_invoiceId = invoiceId;
			_view = view;
			_invoiceTask = invoiceTask;
		}

		public void Initialize( ) {
			DisplayInvoiceDto dto = _invoiceTask.GetInvoiceBy( _invoiceId );
			_view.VendorName = dto.VendorName;
			_view.InvoiceNumber = dto.InvoiceNumber;
			_view.InvoiceDate = dto.InvoiceDate;
			_view.InvoiceTotal = dto.InvoiceTotal;
			_view.PaymentTotal = dto.PaymentTotal;
			_view.CreditTotal = dto.CreditTotal;
			_view.DueDate = dto.DueDate;
			_view.PaymentDate = dto.PaymentDate;
			_view.Terms = dto.Terms;
		}

		public void DeleteInvoice( ) {
			_invoiceTask.DeleteInvoice( _invoiceId );
		}
	}
}