Commit 31cfa5a

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-04-13 21:30:43
trying to refactor the add bill presenter.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@154 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent a7930d1
trunk/product/MyMoney/boot/container/registration/wire_up_the_views_in_to_the.cs
@@ -32,7 +32,7 @@ namespace MoMoney.boot.container.registration
             register.transient<INavigationView, NavigationView>();
             register.transient<IAddCompanyView, AddCompanyView>();
             register.transient<IViewAllBills, ViewAllBills>();
-            register.transient<IAddBillPaymentView, add_bill_payment>();
+            register.transient<IAddBillPaymentView, AddBillPaymentView>();
             register.transient<IMainMenuView, MainMenuView>();
             register.transient<IAddNewIncomeView, AddNewIncomeView>();
             register.transient<IViewIncomeHistory, ViewAllIncome>();
trunk/product/MyMoney/Presentation/Presenters/billing/dto/add_new_bill_dto.cs → trunk/product/MyMoney/Presentation/Presenters/billing/dto/AddNewBillDTO.cs
@@ -2,7 +2,7 @@ using System;
 
 namespace MoMoney.Presentation.Presenters.billing.dto
 {
-    public class add_new_bill_dto
+    public class AddNewBillDTO
     {
         public string company_name { get; set; }
         public DateTime due_date { get; set; }
trunk/product/MyMoney/Presentation/Presenters/billing/AddBillPaymentPresenter.cs
@@ -1,47 +1,53 @@
+using System.Collections.Generic;
 using MoMoney.Domain.accounting.billing;
 using MoMoney.Presentation.Core;
 using MoMoney.Presentation.Presenters.billing.dto;
 using MoMoney.Presentation.Views.billing;
 using MoMoney.Tasks.application;
-using MoMoney.Utility.Extensions;
+using MoMoney.Tasks.infrastructure.core;
 
 namespace MoMoney.Presentation.Presenters.billing
 {
     public interface IAddBillPaymentPresenter : IContentPresenter
     {
-        void submit_bill_payment(add_new_bill_dto dto);
+        void submit_bill_payment(AddNewBillDTO dto);
     }
 
     public class AddBillPaymentPresenter : ContentPresenter<IAddBillPaymentView>, IAddBillPaymentPresenter
     {
         readonly IBillingTasks tasks;
+        readonly ICommandPump pump;
 
-        public AddBillPaymentPresenter(IAddBillPaymentView view, IBillingTasks tasks) : base(view)
+        public AddBillPaymentPresenter(IAddBillPaymentView view, ICommandPump pump, IBillingTasks tasks) : base(view)
         {
+            this.pump = pump;
             this.tasks = tasks;
         }
 
         public override void run()
         {
             view.attach_to(this);
-            view.display(tasks.all_companys());
-            view.display(tasks.all_bills().map_all_using(x => map_from(x)));
+            pump.run<IEnumerable<ICompany>, IGetAllCompanysQuery>(view);
+            pump.run<IEnumerable<bill_information_dto>, IGetAllBillsQuery>(view);
+            //view.run(tasks.all_companys());
+            //view.run(tasks.all_bills().map_all_using(x => map_from(x)));
         }
 
-        public void submit_bill_payment(add_new_bill_dto dto)
+        public void submit_bill_payment(AddNewBillDTO dto)
         {
             tasks.save_a_new_bill_using(dto);
-            view.display(tasks.all_bills().map_all_using(x => map_from(x)));
+            //view.run(tasks.all_bills().map_all_using(x => map_from(x)));
+            pump.run<IEnumerable<bill_information_dto>, IGetAllBillsQuery>(view);
         }
 
-        bill_information_dto map_from(IBill bill)
-        {
-            return new bill_information_dto
-                       {
-                           company_name = bill.company_to_pay.name,
-                           the_amount_owed = bill.the_amount_owed.ToString(),
-                           due_date = bill.due_date.to_date_time(),
-                       };
-        }
+        //bill_information_dto map_from(IBill bill)
+        //{
+        //    return new bill_information_dto
+        //               {
+        //                   company_name = bill.company_to_pay.name,
+        //                   the_amount_owed = bill.the_amount_owed.ToString(),
+        //                   due_date = bill.due_date.to_date_time(),
+        //               };
+        //}
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Views/billing/add_bill_payment.cs → trunk/product/MyMoney/Presentation/Views/billing/AddBillPaymentView.cs
@@ -1,39 +1,44 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using MoMoney.Domain.accounting.billing;
 using MoMoney.Presentation.Databindings;
 using MoMoney.Presentation.Presenters.billing;
 using MoMoney.Presentation.Presenters.billing.dto;
 using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.updates;
 using MoMoney.Utility.Extensions;
 
 namespace MoMoney.Presentation.Views.billing
 {
-    public partial class add_bill_payment : ApplicationDockedWindow, IAddBillPaymentView
+    public partial class AddBillPaymentView : ApplicationDockedWindow, IAddBillPaymentView
     {
-        public add_bill_payment()
+        ControlAction<EventArgs> submit_clicked = x => { };
+
+        public AddBillPaymentView()
         {
             InitializeComponent();
             titled("Add Bill Payment");
+            ux_submit_button.Click += (sender, e) => submit_clicked(e);
         }
 
         public void attach_to(IAddBillPaymentPresenter presenter)
         {
-            ux_submit_button.Click += (sender, e) => presenter.submit_bill_payment(create_dto());
+            submit_clicked = x => presenter.submit_bill_payment(create_dto());
         }
 
-        public void display(IEnumerable<ICompany> companys)
+        public void run(IEnumerable<ICompany> companys)
         {
             ux_company_names.bind_to(companys);
         }
 
-        public void display(IEnumerable<bill_information_dto> bills)
+        public void run(IEnumerable<bill_information_dto> bills)
         {
             ux_bil_payments_grid.DataSource = bills.databind();
         }
 
-        add_new_bill_dto create_dto()
+        AddNewBillDTO create_dto()
         {
-            return new add_new_bill_dto
+            return new AddNewBillDTO
                        {
                            company_name = ux_company_names.SelectedItem.to_string(),
                            due_date = ux_due_date.Value,
trunk/product/MyMoney/Presentation/Views/billing/add_bill_payment.Designer.cs → trunk/product/MyMoney/Presentation/Views/billing/AddBillPaymentView.Designer.cs
@@ -1,6 +1,6 @@
 namespace MoMoney.Presentation.Views.billing
 {
-    partial class add_bill_payment
+    partial class AddBillPaymentView
     {
         /// <summary>
         /// Required designer variable.
@@ -28,7 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(add_bill_payment));
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddBillPaymentView));
             this.kryptonHeaderGroup1 = new ComponentFactory.Krypton.Toolkit.KryptonHeaderGroup();
             this.kryptonSplitContainer1 = new ComponentFactory.Krypton.Toolkit.KryptonSplitContainer();
             this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
trunk/product/MyMoney/Presentation/Views/billing/add_bill_payment.resx → trunk/product/MyMoney/Presentation/Views/billing/AddBillPaymentView.resx
File renamed without changes
trunk/product/MyMoney/Presentation/Views/billing/IAddBillPaymentView.cs
@@ -3,12 +3,14 @@ using MoMoney.Domain.accounting.billing;
 using MoMoney.Presentation.Presenters.billing;
 using MoMoney.Presentation.Presenters.billing.dto;
 using MoMoney.Presentation.Views.core;
+using MoMoney.Utility.Core;
 
 namespace MoMoney.Presentation.Views.billing
 {
-    public interface IAddBillPaymentView : IDockedContentView, IView<IAddBillPaymentPresenter>
+    public interface IAddBillPaymentView : IDockedContentView,
+                                           IView<IAddBillPaymentPresenter>,
+                                           ICallback<IEnumerable<ICompany>>,
+                                           ICallback<IEnumerable<bill_information_dto>>
     {
-        void display(IEnumerable<ICompany> companys);
-        void display(IEnumerable<bill_information_dto> bills);
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Tasks/application/BillingTasks.cs
@@ -8,7 +8,7 @@ namespace MoMoney.Tasks.application
 {
     public interface IBillingTasks
     {
-        void save_a_new_bill_using(add_new_bill_dto dto);
+        void save_a_new_bill_using(AddNewBillDTO dto);
         IEnumerable<IBill> all_bills();
         IEnumerable<ICompany> all_companys();
     }
@@ -26,7 +26,7 @@ namespace MoMoney.Tasks.application
             this.tasks = tasks;
         }
 
-        public void save_a_new_bill_using(add_new_bill_dto dto)
+        public void save_a_new_bill_using(AddNewBillDTO dto)
         {
             var company = companys.find_company_named(dto.company_name);
             var customer = tasks.get_the_current_customer();
trunk/product/MyMoney/Tasks/application/GetAllBillsQuery.cs
@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+using MoMoney.Domain.accounting.billing;
+using MoMoney.Presentation.Presenters.billing.dto;
+using MoMoney.Utility.Core;
+using MoMoney.Utility.Extensions;
+
+namespace MoMoney.Tasks.application
+{
+    public interface IGetAllBillsQuery : IQuery<IEnumerable<bill_information_dto>>
+    {
+    }
+
+    public class GetAllBillsQuery : IGetAllBillsQuery
+    {
+        readonly IBillingTasks tasks;
+
+        public GetAllBillsQuery(IBillingTasks tasks)
+        {
+            this.tasks = tasks;
+        }
+
+        public IEnumerable<bill_information_dto> fetch()
+        {
+            return tasks.all_bills().map_all_using(x => map_from(x));
+        }
+
+        bill_information_dto map_from(IBill bill)
+        {
+            return new bill_information_dto
+                       {
+                           company_name = bill.company_to_pay.name,
+                           the_amount_owed = bill.the_amount_owed.ToString(),
+                           due_date = bill.due_date.to_date_time(),
+                       };
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -402,7 +402,7 @@
     <Compile Include="Presentation\Presenters\billing\AddBillPaymentPresenter.cs" />
     <Compile Include="Presentation\Presenters\AddCompanyPresenter.cs" />
     <Compile Include="Presentation\Presenters\AddCompanyPresenterSpecs.cs" />
-    <Compile Include="Presentation\Presenters\billing\dto\add_new_bill_dto.cs" />
+    <Compile Include="Presentation\Presenters\billing\dto\AddNewBillDTO.cs" />
     <Compile Include="Presentation\Presenters\billing\dto\bill_information_dto.cs" />
     <Compile Include="Presentation\Presenters\billing\dto\RegisterNewCompany.cs" />
     <Compile Include="Presentation\Presenters\billing\ViewAllBillsPresenter.cs" />
@@ -474,11 +474,11 @@
     <Compile Include="Presentation\Views\AddCompanyView.Designer.cs">
       <DependentUpon>AddCompanyView.cs</DependentUpon>
     </Compile>
-    <Compile Include="Presentation\Views\billing\add_bill_payment.cs">
+    <Compile Include="Presentation\Views\billing\AddBillPaymentView.cs">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="Presentation\Views\billing\add_bill_payment.Designer.cs">
-      <DependentUpon>add_bill_payment.cs</DependentUpon>
+    <Compile Include="Presentation\Views\billing\AddBillPaymentView.Designer.cs">
+      <DependentUpon>AddBillPaymentView.cs</DependentUpon>
     </Compile>
     <Compile Include="Presentation\Views\billing\IAddBillPaymentView.cs" />
     <Compile Include="Presentation\Views\core\ApplicationDockedWindow.cs">
@@ -600,6 +600,7 @@
     <Compile Include="Presentation\Views\updates\ICheckForUpdatesView.cs" />
     <Compile Include="Tasks\application\BillingTasks.cs" />
     <Compile Include="Tasks\application\CustomerTasks.cs" />
+    <Compile Include="Tasks\application\GetAllBillsQuery.cs" />
     <Compile Include="Tasks\application\GetAllCompanysQuery.cs" />
     <Compile Include="Tasks\application\IncomeTasks.cs" />
     <Compile Include="Tasks\application\RegisterNewCompanyCommand.cs" />
@@ -755,8 +756,8 @@
       <DependentUpon>AddCompanyView.cs</DependentUpon>
       <SubType>Designer</SubType>
     </EmbeddedResource>
-    <EmbeddedResource Include="Presentation\Views\billing\add_bill_payment.resx">
-      <DependentUpon>add_bill_payment.cs</DependentUpon>
+    <EmbeddedResource Include="Presentation\Views\billing\AddBillPaymentView.resx">
+      <DependentUpon>AddBillPaymentView.cs</DependentUpon>
       <SubType>Designer</SubType>
     </EmbeddedResource>
     <EmbeddedResource Include="Presentation\Views\billing\ViewAllBills.resx">