summaryrefslogtreecommitdiff
path: root/src/app/Cmpp298.Assignment3.Desktop.Presentation
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/Cmpp298.Assignment3.Desktop.Presentation')
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/Cmpp298.Assignment3.Desktop.Presentation.csproj68
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/DeleteInvoicePresenter.cs36
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/EditInvoicePresenter.cs62
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/IDeleteInvoiceView.cs13
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/IEditInvoiceView.cs25
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/IInvoicesMainView.cs9
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/INewInvoiceView.cs25
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/InvoicesMainPresenter.cs31
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/NewInvoicePresenter.cs54
-rw-r--r--src/app/Cmpp298.Assignment3.Desktop.Presentation/Properties/AssemblyInfo.cs35
10 files changed, 358 insertions, 0 deletions
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/Cmpp298.Assignment3.Desktop.Presentation.csproj b/src/app/Cmpp298.Assignment3.Desktop.Presentation/Cmpp298.Assignment3.Desktop.Presentation.csproj
new file mode 100644
index 0000000..f32ce81
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/Cmpp298.Assignment3.Desktop.Presentation.csproj
@@ -0,0 +1,68 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{62EA2002-B0ED-4E9C-945E-B77552A0669C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Cmpp298.Assignment3.Desktop.Presentation</RootNamespace>
+ <AssemblyName>Cmpp298.Assignment3.Desktop.Presentation</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DeleteInvoicePresenter.cs" />
+ <Compile Include="EditInvoicePresenter.cs" />
+ <Compile Include="IDeleteInvoiceView.cs" />
+ <Compile Include="IEditInvoiceView.cs" />
+ <Compile Include="IInvoicesMainView.cs" />
+ <Compile Include="INewInvoiceView.cs" />
+ <Compile Include="InvoicesMainPresenter.cs" />
+ <Compile Include="NewInvoicePresenter.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Cmpp298.Assignment3.Domain\Cmpp298.Assignment3.Domain.csproj">
+ <Project>{C11B2649-751A-4F49-B28D-AB36A8213674}</Project>
+ <Name>Cmpp298.Assignment3.Domain</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Cmpp298.Assignment3.Dto\Cmpp298.Assignment3.Dto.csproj">
+ <Project>{29260A8E-3F7B-4D9B-BBE3-81210F4B9E5B}</Project>
+ <Name>Cmpp298.Assignment3.Dto</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Cmpp298.Assignment3.Task\Cmpp298.Assignment3.Task.csproj">
+ <Project>{A747CA6E-EEA1-42E0-BA90-69317F8BF45D}</Project>
+ <Name>Cmpp298.Assignment3.Task</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/DeleteInvoicePresenter.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/DeleteInvoicePresenter.cs
new file mode 100644
index 0000000..4912e30
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/DeleteInvoicePresenter.cs
@@ -0,0 +1,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 );
+ }
+ }
+} \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/EditInvoicePresenter.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/EditInvoicePresenter.cs
new file mode 100644
index 0000000..eaaf8e6
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/EditInvoicePresenter.cs
@@ -0,0 +1,62 @@
+using Cmpp298.Assignment3.Domain;
+using Cmpp298.Assignment3.Dto;
+using Cmpp298.Assignment3.Task;
+
+namespace Cmpp298.Assignment3.Presentation {
+ public class EditInvoicePresenter {
+ private readonly string _invoiceId;
+ private readonly IEditInvoiceView _view;
+ private readonly IInvoiceTask _task;
+ private readonly ITermTask _termTask;
+
+ public EditInvoicePresenter( string invoiceId, IEditInvoiceView view )
+ : this( invoiceId, view, new InvoiceTask( ), new TermTask( ) ) {}
+
+ public EditInvoicePresenter( string invoiceId, IEditInvoiceView view, IInvoiceTask task, ITermTask termTask ) {
+ _view = view;
+ _task = task;
+ _termTask = termTask;
+ _invoiceId = invoiceId;
+ }
+
+ public void Initialize( ) {
+ _view.TermsDropDown.BindTo( _termTask.GetAll( ) );
+ UpdateViewFrom( _task.GetInvoiceBy( _invoiceId ) );
+ }
+
+ public void UpdateInvoice( ) {
+ if ( IsValidInput( ) ) {
+ _task.UpdateInvoice( CreateDtoFromView( ) );
+ }
+ else {
+ _view.ShowError( "Invalid input detected" );
+ }
+ }
+
+ private void UpdateViewFrom( DisplayInvoiceDto dto ) {
+ _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.TermsDropDown.SetSelectedItemTo( dto.Terms );
+ }
+
+ private bool IsValidInput( ) {
+ AmountEntrySpecification specification = new AmountEntrySpecification( );
+ return
+ specification.IsSatisfiedBy( _view.CreditTotal )
+ && specification.IsSatisfiedBy( _view.PaymentTotal )
+ && specification.IsSatisfiedBy( _view.InvoiceTotal );
+ }
+
+ private UpdateInvoiceDto CreateDtoFromView( ) {
+ return
+ new UpdateInvoiceDto( _invoiceId, _view.InvoiceNumber, _view.InvoiceDate, _view.InvoiceTotal, _view.PaymentTotal,
+ _view.CreditTotal, _view.DueDate, _view.PaymentDate, _view.TermsDropDown.SelectedItem.Value );
+ }
+ }
+} \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/IDeleteInvoiceView.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/IDeleteInvoiceView.cs
new file mode 100644
index 0000000..fb547bf
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/IDeleteInvoiceView.cs
@@ -0,0 +1,13 @@
+namespace Cmpp298.Assignment3.Presentation {
+ public interface IDeleteInvoiceView {
+ string VendorName { set; }
+ string InvoiceNumber { set; }
+ string InvoiceDate { set; }
+ string InvoiceTotal { set; }
+ string PaymentTotal { set; }
+ string CreditTotal { set; }
+ string DueDate { set; }
+ string PaymentDate { set; }
+ string Terms { set; }
+ }
+} \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/IEditInvoiceView.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/IEditInvoiceView.cs
new file mode 100644
index 0000000..d9c195e
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/IEditInvoiceView.cs
@@ -0,0 +1,25 @@
+using Cmpp298.Assignment3.Dto;
+
+namespace Cmpp298.Assignment3.Presentation {
+ public interface IEditInvoiceView {
+ IDropDownListAdapter TermsDropDown { get; }
+
+ string VendorName { get; set; }
+
+ string InvoiceNumber { get; set; }
+
+ string InvoiceDate { get; set; }
+
+ string InvoiceTotal { get; set; }
+
+ string PaymentTotal { get; set; }
+
+ string CreditTotal { get; set; }
+
+ string DueDate { get; set; }
+
+ string PaymentDate { get; set; }
+
+ void ShowError( string message );
+ }
+} \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/IInvoicesMainView.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/IInvoicesMainView.cs
new file mode 100644
index 0000000..bdb3fc2
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/IInvoicesMainView.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+using Cmpp298.Assignment3.Dto;
+
+namespace Cmpp298.Assignment3.Presentation {
+ public interface IInvoicesMainView {
+ IDropDownListAdapter VendorNames { get; }
+ void BindTo( IEnumerable< DisplayInvoiceDto > invoices );
+ }
+} \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/INewInvoiceView.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/INewInvoiceView.cs
new file mode 100644
index 0000000..9b74a93
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/INewInvoiceView.cs
@@ -0,0 +1,25 @@
+using Cmpp298.Assignment3.Dto;
+
+namespace Cmpp298.Assignment3.Presentation {
+ public interface INewInvoiceView {
+ void BindTo( DisplayVendorNameDto displayVendorNameDto );
+
+ IDropDownListAdapter Terms { get; }
+
+ string InvoiceNumber { get; set; }
+
+ string InvoiceDate { get; }
+
+ string InvoiceTotal { get; }
+
+ string PaymentTotal { get; }
+
+ string CreditTotal { get; }
+
+ string DueDate { get; }
+
+ string PaymentDate { get; }
+
+ void ShowError( string message );
+ }
+} \ No newline at end of file
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
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/NewInvoicePresenter.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/NewInvoicePresenter.cs
new file mode 100644
index 0000000..83f30dc
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/NewInvoicePresenter.cs
@@ -0,0 +1,54 @@
+using System;
+using Cmpp298.Assignment3.Domain;
+using Cmpp298.Assignment3.Dto;
+using Cmpp298.Assignment3.Task;
+
+namespace Cmpp298.Assignment3.Presentation {
+ public class NewInvoicePresenter {
+ private readonly string _vendorId;
+ private readonly INewInvoiceView _view;
+ private readonly IInvoiceTask _invoiceTask;
+ private readonly IVendorTask _vendorTask;
+ private readonly ITermTask _termTask;
+
+ public NewInvoicePresenter( string vendorId, INewInvoiceView view )
+ : this( vendorId, view, new InvoiceTask( ), new VendorTask( ), new TermTask( ) ) {}
+
+ public NewInvoicePresenter( string vendorId, INewInvoiceView view, IInvoiceTask invoiceTask, IVendorTask vendorTask,
+ ITermTask termTask ) {
+ _vendorId = vendorId;
+ _view = view;
+ _invoiceTask = invoiceTask;
+ _vendorTask = vendorTask;
+ _termTask = termTask;
+ }
+
+ public void Load( ) {
+ _view.BindTo( _vendorTask.FindVendorNameBy( _vendorId ) );
+ _view.InvoiceNumber = Guid.NewGuid( ).ToString( );
+ _view.Terms.BindTo( _termTask.GetAll( ) );
+ }
+
+ public void SaveInvoice( ) {
+ if ( IsValidInput( ) ) {
+ _invoiceTask.SaveNewInvoice( CreateDtoFromView( ) );
+ }
+ else {
+ _view.ShowError( "Invalid input detected!" );
+ }
+ }
+
+ private bool IsValidInput( ) {
+ AmountEntrySpecification specification = new AmountEntrySpecification( );
+ return
+ specification.IsSatisfiedBy( _view.CreditTotal )
+ && specification.IsSatisfiedBy( _view.PaymentTotal )
+ && specification.IsSatisfiedBy( _view.InvoiceTotal );
+ }
+
+ private SaveInvoiceDto CreateDtoFromView( ) {
+ return new SaveInvoiceDto( _vendorId, _view.InvoiceNumber, _view.InvoiceDate, _view.InvoiceTotal, _view.PaymentTotal,
+ _view.CreditTotal, _view.DueDate, _view.PaymentDate, _view.Terms.SelectedItem.Value );
+ }
+ }
+} \ No newline at end of file
diff --git a/src/app/Cmpp298.Assignment3.Desktop.Presentation/Properties/AssemblyInfo.cs b/src/app/Cmpp298.Assignment3.Desktop.Presentation/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b2a7f1d
--- /dev/null
+++ b/src/app/Cmpp298.Assignment3.Desktop.Presentation/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Cmpp298.Assignment3.Desktop.Presentation")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Cmpp298.Assignment3.Desktop.Presentation")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("38eca514-6401-4b26-b3bf-19b7ae2f8b80")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]