Commit a086f5b
Changed files (71)
trunk
product
Gorilla.Commons.Utility
Gorilla.Commons.Windows.Forms
Gorilla.Commons.Windows.Forms.ThirdParty
MoMoney.Domain
MoMoney.DTO
MoMoney.Presentation
Core
Model
Presenters
Views
Core
Dialogs
Navigation
Reporting
Updates
MoMoney.Service
MyMoney
boot
trunk/product/Gorilla.Commons.Utility/Core/ComponentFactory.cs
@@ -0,0 +1,14 @@
+namespace Gorilla.Commons.Utility.Core
+{
+ public interface IComponentFactory<T> : IFactory<T> where T : new()
+ {
+ }
+
+ public class ComponentFactory<T> : IComponentFactory<T> where T : new()
+ {
+ public T create()
+ {
+ return new T();
+ }
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Utility/Core/Factory.cs
@@ -1,14 +1,6 @@
namespace Gorilla.Commons.Utility.Core
{
- public interface IComponentFactory<T> : IFactory<T> where T : new()
- {
- }
+ public delegate Out Factory<In, Out>(In input);
- public class Factory<T> : IComponentFactory<T> where T : new()
- {
- public T create()
- {
- return new T();
- }
- }
+ public delegate Out Factory<Out>();
}
\ No newline at end of file
trunk/product/Gorilla.Commons.Utility/Gorilla.Commons.Utility.csproj
@@ -67,6 +67,7 @@
<Compile Include="Core\DisposableCommand.cs" />
<Compile Include="Core\EmptyCallback.cs" />
<Compile Include="Core\EmptyCommand.cs" />
+ <Compile Include="Core\ComponentFactory.cs" />
<Compile Include="Core\Factory.cs" />
<Compile Include="Core\IBuilder.cs" />
<Compile Include="Core\ICallback.cs" />
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/BindableListBox.cs
@@ -1,32 +1,30 @@
using System.Collections.Generic;
+using Gorilla.Commons.Utility.Extensions;
namespace Gorilla.Commons.Windows.Forms.Helpers
{
- public class BindableListBox<ItemToBindTo> : IBindableList<ItemToBindTo>
+ public class BindableListBox<TItemToBindTo> : IBindableList<TItemToBindTo>
{
- readonly IListControl<ItemToBindTo> listControl;
+ readonly IListControl<TItemToBindTo> list_control;
- public BindableListBox(IListControl<ItemToBindTo> listControl)
+ public BindableListBox(IListControl<TItemToBindTo> list_control)
{
- this.listControl = listControl;
+ this.list_control = list_control;
}
- public void bind_to(IEnumerable<ItemToBindTo> items)
+ public void bind_to(IEnumerable<TItemToBindTo> items)
{
- foreach (var item in items)
- {
- listControl.add_item(item);
- }
+ items.each(x => list_control.add_item(x));
}
- public ItemToBindTo get_selected_item()
+ public TItemToBindTo get_selected_item()
{
- return listControl.get_selected_item();
+ return list_control.get_selected_item();
}
- public void set_selected_item(ItemToBindTo item)
+ public void set_selected_item(TItemToBindTo item)
{
- listControl.set_selected_item(item);
+ list_control.set_selected_item(item);
}
}
}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/BindableListExtensions.cs
@@ -0,0 +1,17 @@
+using System.Windows.Forms;
+
+namespace Gorilla.Commons.Windows.Forms.Helpers
+{
+ static public class BindableListExtensions
+ {
+ static public IBindableList<TItemToBindTo> create_for<TItemToBindTo>(this ListBox listbox)
+ {
+ return BindableListFactory.create_for(new ListBoxListControl<TItemToBindTo>(listbox));
+ }
+
+ static public IBindableList<TItemToBindTo> create_for<TItemToBindTo>(this ComboBox combobox)
+ {
+ return BindableListFactory.create_for(new ComboBoxListControl<TItemToBindTo>(combobox));
+ }
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/BindableListFactory.cs
@@ -1,17 +1,10 @@
-using System.Windows.Forms;
-
namespace Gorilla.Commons.Windows.Forms.Helpers
{
static public class BindableListFactory
{
- static public IBindableList<ItemToBindTo> create_for<ItemToBindTo>(ListBox listbox)
+ static public IBindableList<TItemToBindTo> create_for<TItemToBindTo>(IListControl<TItemToBindTo> list_control)
{
- return new BindableListBox<ItemToBindTo>(new ListBoxListControl<ItemToBindTo>(listbox));
- }
-
- static public IBindableList<ItemToBindTo> create_for<ItemToBindTo>(ComboBox combobox)
- {
- return new BindableListBox<ItemToBindTo>(new ComboBoxListControl<ItemToBindTo>(combobox));
+ return new BindableListBox<TItemToBindTo>(list_control);
}
}
}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/ComboBoxListControl.cs
@@ -2,7 +2,7 @@ using System.Windows.Forms;
namespace Gorilla.Commons.Windows.Forms.Helpers
{
- public class ComboBoxListControl<ItemToStore> : IListControl<ItemToStore>
+ public class ComboBoxListControl<TItemToStore> : IListControl<TItemToStore>
{
readonly ComboBox combo_box;
@@ -11,26 +11,21 @@ namespace Gorilla.Commons.Windows.Forms.Helpers
this.combo_box = combo_box;
}
- public ItemToStore get_selected_item()
+ public TItemToStore get_selected_item()
{
- return (ItemToStore) combo_box.SelectedItem;
+ return (TItemToStore) combo_box.SelectedItem;
}
- public void add_item(ItemToStore item)
+ public void add_item(TItemToStore item)
{
combo_box.Items.Add(item);
combo_box.SelectedIndex = 0;
}
- public void set_selected_item(ItemToStore item)
+ public void set_selected_item(TItemToStore item)
{
- if (!Equals(item, default(ItemToStore)))
- {
- if (combo_box.Items.Contains(item))
- {
- combo_box.SelectedItem = item;
- }
- }
+ if (!Equals(item, default(TItemToStore)))
+ if (combo_box.Items.Contains(item)) combo_box.SelectedItem = item;
}
}
}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/ControlExtensions.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Windows.Forms;
+
+namespace Gorilla.Commons.Windows.Forms.Helpers
+{
+ static public class ControlExtensions
+ {
+ static public IDisposable suspend_layout(this Control control)
+ {
+ return new SuspendLayout(control);
+ }
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/IBindableList.cs
@@ -2,10 +2,10 @@ using System.Collections.Generic;
namespace Gorilla.Commons.Windows.Forms.Helpers
{
- public interface IBindableList<ItemToBindTo>
+ public interface IBindableList<TItemToBindTo>
{
- void bind_to(IEnumerable<ItemToBindTo> items);
- ItemToBindTo get_selected_item();
- void set_selected_item(ItemToBindTo item);
+ void bind_to(IEnumerable<TItemToBindTo> items);
+ TItemToBindTo get_selected_item();
+ void set_selected_item(TItemToBindTo item);
}
}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Helpers/ListBoxListControl.cs
@@ -2,7 +2,7 @@ using System.Windows.Forms;
namespace Gorilla.Commons.Windows.Forms.Helpers
{
- public class ListBoxListControl<ItemToStore> : IListControl<ItemToStore>
+ public class ListBoxListControl<TItemToStore> : IListControl<TItemToStore>
{
readonly ListBox list_box;
@@ -11,22 +11,19 @@ namespace Gorilla.Commons.Windows.Forms.Helpers
this.list_box = list_box;
}
- public ItemToStore get_selected_item()
+ public TItemToStore get_selected_item()
{
- return (ItemToStore) list_box.SelectedItem;
+ return (TItemToStore) list_box.SelectedItem;
}
- public void add_item(ItemToStore item)
+ public void add_item(TItemToStore item)
{
list_box.Items.Add(item);
}
- public void set_selected_item(ItemToStore item)
+ public void set_selected_item(TItemToStore item)
{
- if (list_box.Items.Contains(item))
- {
- list_box.SelectedItem = item;
- }
+ if (list_box.Items.Contains(item)) list_box.SelectedItem = item;
}
}
}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms/Gorilla.Commons.Windows.Forms.csproj
@@ -77,6 +77,7 @@
<Compile Include="Databinding\TextBoxDataBindingSpecs.cs" />
<Compile Include="Databinding\TextPropertyBinding.cs" />
<Compile Include="Helpers\BindableListBox.cs" />
+ <Compile Include="Helpers\BindableListExtensions.cs" />
<Compile Include="Helpers\BindableListFactory.cs" />
<Compile Include="Helpers\BitmapRegion.cs" />
<Compile Include="Helpers\ButtonExtensions.cs" />
@@ -84,6 +85,7 @@
<Compile Include="Helpers\ControlAdapter.cs">
<SubType>Component</SubType>
</Compile>
+ <Compile Include="Helpers\ControlExtensions.cs" />
<Compile Include="Helpers\Events.cs" />
<Compile Include="Helpers\EventTrigger.cs" />
<Compile Include="Helpers\EventTriggerExtensions.cs" />
trunk/product/Gorilla.Commons.Windows.Forms.ThirdParty/Krypton/BindableListExtensions.cs
@@ -0,0 +1,18 @@
+using ComponentFactory.Krypton.Toolkit;
+using Gorilla.Commons.Windows.Forms.Helpers;
+
+namespace Gorilla.Commons.Windows.Forms.Krypton
+{
+ static public class BindableListExtensions
+ {
+ static public IBindableList<TItemToBindTo> create_for<TItemToBindTo>(this KryptonListBox listbox)
+ {
+ return BindableListFactory.create_for(new KryptonListBoxListControl<TItemToBindTo>(listbox));
+ }
+
+ static public IBindableList<TItemToBindTo> create_for<TItemToBindTo>(this KryptonComboBox combobox)
+ {
+ return BindableListFactory.create_for(new KryptonComboBoxListControl<TItemToBindTo>(combobox));
+ }
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms.ThirdParty/Krypton/KryptonComboBoxListControl.cs
@@ -0,0 +1,32 @@
+using ComponentFactory.Krypton.Toolkit;
+using Gorilla.Commons.Windows.Forms.Helpers;
+
+namespace Gorilla.Commons.Windows.Forms.Krypton
+{
+ public class KryptonComboBoxListControl<TItemToStore> : IListControl<TItemToStore>
+ {
+ readonly KryptonComboBox combo_box;
+
+ public KryptonComboBoxListControl(KryptonComboBox combo_box)
+ {
+ this.combo_box = combo_box;
+ }
+
+ public TItemToStore get_selected_item()
+ {
+ return (TItemToStore) combo_box.SelectedItem;
+ }
+
+ public void add_item(TItemToStore item)
+ {
+ combo_box.Items.Add(item);
+ combo_box.SelectedIndex = 0;
+ }
+
+ public void set_selected_item(TItemToStore item)
+ {
+ if (!Equals(item, default(TItemToStore)))
+ if (combo_box.Items.Contains(item)) combo_box.SelectedItem = item;
+ }
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms.ThirdParty/Krypton/KryptonListBoxListControl.cs
@@ -0,0 +1,30 @@
+using ComponentFactory.Krypton.Toolkit;
+using Gorilla.Commons.Windows.Forms.Helpers;
+
+namespace Gorilla.Commons.Windows.Forms.Krypton
+{
+ public class KryptonListBoxListControl<TItemToStore> : IListControl<TItemToStore>
+ {
+ readonly KryptonListBox list_box;
+
+ public KryptonListBoxListControl(KryptonListBox list_box)
+ {
+ this.list_box = list_box;
+ }
+
+ public TItemToStore get_selected_item()
+ {
+ return (TItemToStore) list_box.SelectedItem;
+ }
+
+ public void add_item(TItemToStore item)
+ {
+ list_box.Items.Add(item);
+ }
+
+ public void set_selected_item(TItemToStore item)
+ {
+ if (list_box.Items.Contains(item)) list_box.SelectedItem = item;
+ }
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Windows.Forms.ThirdParty/Gorilla.Commons.Windows.Forms.ThirdParty.csproj
@@ -50,6 +50,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Krypton\BindableListExtensions.cs" />
+ <Compile Include="Krypton\KryptonComboBoxListControl.cs" />
+ <Compile Include="Krypton\KryptonListBoxListControl.cs" />
<Compile Include="Krypton\ListboxExtensions.cs" />
</ItemGroup>
<ItemGroup>
@@ -57,6 +60,10 @@
<Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
<Name>Gorilla.Commons.Utility</Name>
</ProjectReference>
+ <ProjectReference Include="..\Gorilla.Commons.Windows.Forms\Gorilla.Commons.Windows.Forms.csproj">
+ <Project>{54B55B2B-A58F-45DF-A446-234C9D70DC0B}</Project>
+ <Name>Gorilla.Commons.Windows.Forms</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
trunk/product/MoMoney.Domain/Core/range_specs.cs โ trunk/product/MoMoney.Domain/Core/RangeSpecs.cs
@@ -3,6 +3,10 @@ using Gorilla.Commons.Testing;
namespace MoMoney.Domain.Core
{
+ public class RangeSpecs
+ {
+ }
+
[Concern(typeof (Range<int>))]
public abstract class behaves_like_a_range_from_1_to_10 : concerns_for<IRange<int>>
{
trunk/product/MoMoney.Domain/Core/Ranking.cs
@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+
+namespace MoMoney.Domain.Core
+{
+ public interface IRanking<T> : IComparer<T>
+ {
+ void add(T item);
+ }
+
+ public class Ranking<T> : IRanking<T>
+ {
+ readonly IList<T> ranked_items;
+
+ public Ranking()
+ {
+ ranked_items = new List<T>();
+ }
+
+ public void add(T item)
+ {
+ ranked_items.Add(item);
+ }
+
+ public int Compare(T x, T y)
+ {
+ var x_ranking = get_ranking_for(x);
+ var y_ranking = get_ranking_for(y);
+ if (x_ranking.Equals(y_ranking)) return 0;
+ return x_ranking < y_ranking ? 1 : -1;
+ }
+
+ int get_ranking_for(T item)
+ {
+ return ranked_items.IndexOf(item) == -1 ? int.MaxValue : ranked_items.IndexOf(item);
+ }
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Domain/Core/RankingSpecs.cs
@@ -0,0 +1,76 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace MoMoney.Domain.Core
+{
+ public class RankingSpecs
+ {
+ }
+
+ public abstract class behaves_like_a_list_of_calgary_flames_point_leaders : concerns_for<IRanking<string>, Ranking<string>>
+ {
+ after_the_sut_has_been_created c = () =>
+ {
+ sut.add("Jarome Iginla");
+ sut.add("Mike Cammalleri");
+ sut.add("Daymond Langkow");
+ sut.add("Todd Bertuzzi");
+ sut.add("Rene Bourque");
+ sut.add("Dion Phaneuf");
+ sut.add("Craig Conroy");
+ sut.add("Curtis Glencross");
+ sut.add("David Moss");
+ sut.add("Adrian Aucoin");
+ };
+ }
+
+ public class when_someone_ranked_higher_is_compared_with_someone_ranked_lower :
+ behaves_like_a_list_of_calgary_flames_point_leaders
+ {
+ it the_higher_ranked_player_should_be_revealed = () => result.should_be_greater_than(0);
+
+ because b = () => { result = sut.Compare("Jarome Iginla", "Mike Cammalleri"); };
+
+ static int result;
+ }
+
+ public class when_someone_ranked_lower_is_compared_with_someone_ranked_higher :
+ behaves_like_a_list_of_calgary_flames_point_leaders
+ {
+ it the_lower_ranked_player_should_be_revealed = () => result.should_be_less_than(0);
+
+ because b = () => { result = sut.Compare("Mike Cammalleri", "Jarome Iginla"); };
+
+ static int result;
+ }
+
+ public class when_a_ranked_player_is_compared_with_them_selves :
+ behaves_like_a_list_of_calgary_flames_point_leaders
+ {
+ it should_indicate_that_they_are_ranked_the_same = () => result.should_be_equal_to(0);
+
+ because b = () => { result = sut.Compare("David Moss", "David Moss"); };
+
+ static int result;
+ }
+
+ public class when_an_unranked_player_is_compared_to_a_ranked_player :
+ behaves_like_a_list_of_calgary_flames_point_leaders
+ {
+ it should_ranked_the_ranked_player_higher = () => result.should_be_less_than(0);
+
+ because b = () => { result = sut.Compare("Brett Sutter", "Jarome Iginla"); };
+
+ static int result;
+ }
+
+ public class when_an_ranked_player_is_compared_to_a_unranked_player :
+ behaves_like_a_list_of_calgary_flames_point_leaders
+ {
+ it should_ranked_the_ranked_player_higher = () => result.should_be_greater_than(0);
+
+ because b = () => { result = sut.Compare("Jarome Iginla", "Brett Sutter"); };
+
+ static int result;
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Domain/MoMoney.Domain.csproj
@@ -83,7 +83,9 @@
<Compile Include="Core\Month.cs" />
<Compile Include="Core\Months.cs" />
<Compile Include="Core\range.cs" />
- <Compile Include="Core\range_specs.cs" />
+ <Compile Include="Core\RangeSpecs.cs" />
+ <Compile Include="Core\Ranking.cs" />
+ <Compile Include="Core\RankingSpecs.cs" />
<Compile Include="Repositories\IAccountHolderRepository.cs" />
<Compile Include="Repositories\IBillRepository.cs" />
<Compile Include="Repositories\ICompanyRepository.cs" />
trunk/product/MoMoney.DTO/IncomeSubmissionDto.cs
@@ -1,6 +1,6 @@
using System;
-namespace MoMoney.Presentation.Presenters.income.dto
+namespace MoMoney.DTO
{
public class IncomeSubmissionDto
{
trunk/product/MoMoney.Presentation/Core/ApplicationController.cs
@@ -34,9 +34,9 @@ namespace MoMoney.Presentation.Core
var view = content_presenter.View;
//view.on_activated = x => content_presenter.activate();
- //view.on_deactivate = x => content_presenter.deactivate();
+ //view.deactivated = x => content_presenter.deactivate();
//view.on_closing = x => x.Cancel = !content_presenter.can_close();
- //view.on_closed = x => remove(presenter);
+ //view.closed = x => remove(presenter);
shell.add(view);
}
trunk/product/MoMoney.Presentation/Core/ApplicationControllerSpecs.cs
@@ -1,6 +1,6 @@
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
using MoMoney.Presentation.Views.Shell;
namespace MoMoney.Presentation.Core
@@ -15,8 +15,8 @@ namespace MoMoney.Presentation.Core
shell = the_dependency<IShell>();
};
- protected static IShell shell;
- protected static IPresenterRegistry presenter_registry;
+ static protected IShell shell;
+ static protected IPresenterRegistry presenter_registry;
}
public class when_the_application_controller_is_asked_to_run_a_presenter : behaves_like_an_application_controller
trunk/product/MoMoney.Presentation/Core/ContentPresenter.cs
@@ -1,4 +1,4 @@
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Core
{
trunk/product/MoMoney.Presentation/Core/IContentPresenter.cs
@@ -1,4 +1,4 @@
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Core
{
trunk/product/MoMoney.Presentation/Model/Projects/ProjectController.cs
@@ -4,19 +4,19 @@ using Gorilla.Commons.Infrastructure.Logging;
using Gorilla.Commons.Infrastructure.Transactions;
using Gorilla.Commons.Utility.Core;
using Gorilla.Commons.Utility.Extensions;
-using MoMoney.DataAccess;
using MoMoney.Presentation.Model.messages;
+using MoMoney.Service.Infrastructure;
namespace MoMoney.Presentation.Model.Projects
{
public class ProjectController : IProjectController, ICallback<IUnitOfWork>
{
readonly IEventAggregator broker;
- readonly IDatabaseConfiguration configuration;
+ readonly IProjectTasks configuration;
IProject project;
bool unsaved_changes = false;
- public ProjectController(IEventAggregator broker, IDatabaseConfiguration configuration)
+ public ProjectController(IEventAggregator broker, IProjectTasks configuration)
{
this.broker = broker;
this.configuration = configuration;
trunk/product/MoMoney.Presentation/Model/Projects/ProjectControllerSpecs.cs
@@ -5,8 +5,8 @@ using Gorilla.Commons.Infrastructure.FileSystem;
using Gorilla.Commons.Infrastructure.Transactions;
using Gorilla.Commons.Testing;
using Gorilla.Commons.Utility.Extensions;
-using MoMoney.DataAccess;
using MoMoney.Presentation.Model.messages;
+using MoMoney.Service.Infrastructure;
namespace MoMoney.Presentation.Model.Projects
{
@@ -20,11 +20,11 @@ namespace MoMoney.Presentation.Model.Projects
context c = () =>
{
broker = the_dependency<IEventAggregator>();
- configuration = the_dependency<IDatabaseConfiguration>();
+ tasks = the_dependency<IProjectTasks>();
};
- protected static IEventAggregator broker;
- protected static IDatabaseConfiguration configuration;
+ static protected IEventAggregator broker;
+ static protected IProjectTasks tasks;
}
public class when_saving_the_current_project : behaves_like_a_project
@@ -60,7 +60,7 @@ namespace MoMoney.Presentation.Model.Projects
public class when_specifying_a_new_path_to_save_an_opened_project_to : behaves_like_a_project
{
- it should_save_the_current_database_to_the_new_path = () => configuration.was_told_to(x => x.copy_to("blah"));
+ it should_save_the_current_database_to_the_new_path = () => tasks.was_told_to(x => x.copy_to("blah"));
context c = () =>
{
trunk/product/MoMoney.Presentation/Presenters/Commands/RunThe.cs
@@ -4,24 +4,24 @@ using MoMoney.Presentation.Core;
namespace MoMoney.Presentation.Presenters.Commands
{
- public interface IRunThe<Presenter> : ICommand where Presenter : IPresenter
+ public interface IRunThe<TPresenter> : ICommand where TPresenter : IPresenter
{
}
- public class RunThe<Presenter> : IRunThe<Presenter> where Presenter : IPresenter
+ public class RunThe<TPresenter> : IRunThe<TPresenter> where TPresenter : IPresenter
{
- readonly IApplicationController application_controller;
+ readonly IApplicationController controller;
readonly ICommandProcessor processor;
- public RunThe(IApplicationController application_controller, ICommandProcessor processor)
+ public RunThe(IApplicationController controller, ICommandProcessor processor)
{
- this.application_controller = application_controller;
+ this.controller = controller;
this.processor = processor;
}
public void run()
{
- processor.add(() => application_controller.run<Presenter>());
+ processor.add(() => controller.run<TPresenter>());
}
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Presenters/Commands/RunTheSpecs.cs
@@ -1,4 +1,5 @@
using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Infrastructure.Threading;
using Gorilla.Commons.Testing;
using MoMoney.Presentation.Core;
@@ -12,13 +13,18 @@ namespace MoMoney.Presentation.Presenters.Commands
public class when_initializing_different_regions_of_the_user_interface :
concerns_for<IRunThe<IPresenter>, RunThe<IPresenter>>
{
- it should_initialize_the_presenter_that_controls_that_region =
- () => application_controller.was_told_to(x => x.run<IPresenter>());
+ //it should_initialize_the_presenter_that_controls_that_region = () => controller.was_told_to(x => x.run<IPresenter>());
+ it should_initialize_the_presenter_that_controls_that_region = () => processor.was_told_to(x => x.add(() => controller.run<IPresenter>()));
- context c = () => { application_controller = the_dependency<IApplicationController>(); };
+ context c = () =>
+ {
+ controller = the_dependency<IApplicationController>();
+ processor = the_dependency<ICommandProcessor>();
+ };
because b = () => sut.run();
- static IApplicationController application_controller;
+ static IApplicationController controller;
+ static ICommandProcessor processor;
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Presenters/Menu/AboutTheApplicationPresenter.cs
@@ -1,5 +1,5 @@
using MoMoney.Presentation.Core;
-using MoMoney.Presentation.Views.Menu.Help;
+using MoMoney.Presentation.Views.Menu;
namespace MoMoney.Presentation.Presenters.Menu.Help
{
trunk/product/MoMoney.Presentation/Presenters/Shell/NotificationPresenter.cs
@@ -0,0 +1,17 @@
+using System.Text;
+using System.Windows.Forms;
+using Gorilla.Commons.Utility.Extensions;
+using MoMoney.Service.Application;
+
+namespace MoMoney.Presentation.Presenters.Shell
+{
+ public class NotificationPresenter : INotification
+ {
+ public void notify(params NotificationMessage[] messages)
+ {
+ var builder = new StringBuilder();
+ messages.each(x => builder.AppendLine(x));
+ MessageBox.Show(builder.ToString(), "Ooops...", MessageBoxButtons.OK);
+ }
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Presenters/AddCompanyPresenter.cs
@@ -1,7 +1,5 @@
using System.Collections.Generic;
-using System.Linq;
using Gorilla.Commons.Infrastructure;
-using Gorilla.Commons.Utility.Extensions;
using MoMoney.DTO;
using MoMoney.Presentation.Core;
using MoMoney.Presentation.Views;
@@ -17,13 +15,11 @@ namespace MoMoney.Presentation.Presenters
public class AddCompanyPresenter : ContentPresenter<IAddCompanyView>, IAddCompanyPresenter
{
- readonly IBillingTasks tasks;
readonly ICommandPump pump;
- public AddCompanyPresenter(IAddCompanyView view, IBillingTasks tasks, ICommandPump pump) : base(view)
+ public AddCompanyPresenter(IAddCompanyView view, ICommandPump pump) : base(view)
{
this.pump = pump;
- this.tasks = tasks;
}
public override void run()
@@ -34,22 +30,9 @@ namespace MoMoney.Presentation.Presenters
public void submit(RegisterNewCompany dto)
{
- if (company_has_already_been_registered(dto))
- view.notify(create_error_message_from(dto));
- else
- pump
- .run<IRegisterNewCompanyCommand, RegisterNewCompany>(dto)
- .run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view);
- }
-
- bool company_has_already_been_registered(RegisterNewCompany dto)
- {
- return tasks.all_companys().Count(x => x.name.is_equal_to_ignoring_case(dto.company_name)) > 0;
- }
-
- string create_error_message_from(RegisterNewCompany dto)
- {
- return "A Company named {0}, has already been submitted!".formatted_using(dto.company_name);
+ pump
+ .run<IRegisterNewCompanyCommand, RegisterNewCompany>(dto)
+ .run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view);
}
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Presenters/AddCompanyPresenterSpecs.cs
@@ -4,7 +4,6 @@ using Gorilla.Commons.Testing;
using MoMoney.DTO;
using MoMoney.Presentation.Views;
using MoMoney.Service.Application;
-using MoMoney.Tasks.application;
namespace MoMoney.Presentation.Presenters
{
@@ -15,12 +14,10 @@ namespace MoMoney.Presentation.Presenters
context c = () =>
{
view = the_dependency<IAddCompanyView>();
- tasks = the_dependency<IBillingTasks>();
pump = the_dependency<ICommandPump>();
};
protected static IAddCompanyView view;
- protected static IBillingTasks tasks;
protected static ICommandPump pump;
}
@@ -31,18 +28,18 @@ namespace MoMoney.Presentation.Presenters
because b = () => sut.run();
}
+ [Concern(typeof (AddCompanyPresenter))]
public class when_registering_a_new_company : behaves_like_the_add_company_presenter
{
context c = () =>
{
dto = new RegisterNewCompany {company_name = "Microsoft"};
- when_the(tasks).is_asked_for(x => x.all_companys()).it_will_return_nothing();
when_the(pump)
.is_told_to(x => x.run<IRegisterNewCompanyCommand, RegisterNewCompany>(dto))
.it_will_return(pump);
};
- because b = () => { sut.submit(dto); };
+ because b = () => sut.submit(dto);
it should_add_the_new_company =
() => pump.was_told_to(x => x.run<IRegisterNewCompanyCommand, RegisterNewCompany>(dto));
trunk/product/MoMoney.Presentation/Views/Billing/IAddBillPaymentView.cs
@@ -3,7 +3,7 @@ using Gorilla.Commons.Utility.Core;
using MoMoney.DTO;
using MoMoney.Presentation.Presenters.billing;
using MoMoney.Presentation.Presenters.billing.dto;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.billing
{
trunk/product/MoMoney.Presentation/Views/Billing/IViewAllBills.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
using Gorilla.Commons.Utility.Core;
using MoMoney.Presentation.Presenters.billing;
using MoMoney.Presentation.Presenters.billing.dto;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.billing
{
trunk/product/MoMoney.Presentation/Views/Core/ApplicationDockedWindow.cs
@@ -7,6 +7,7 @@ using Gorilla.Commons.Windows.Forms;
using Gorilla.Commons.Windows.Forms.Helpers;
using Gorilla.Commons.Windows.Forms.Resources;
using MoMoney.Presentation.Resources;
+using MoMoney.Presentation.Views.Core;
using WeifenLuo.WinFormsUI.Docking;
namespace MoMoney.Presentation.Views.core
@@ -31,40 +32,40 @@ namespace MoMoney.Presentation.Views.core
dock_state = DockState.Document;
HideOnClose = true;
- on_activated = x => { };
- on_deactivate = x => { };
- on_closed = x => { };
- on_closing = x => { };
+ activated = x => { };
+ deactivated = x => { };
+ closed = x => { };
+ closing = x => { };
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
- on_activated(e);
+ activated(e);
}
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
- on_deactivate(e);
+ deactivated(e);
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
- on_closing(e);
+ closing(e);
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
- on_closed(e);
+ closed(e);
}
- public ControlAction<EventArgs> on_activated { get; set; }
- public ControlAction<EventArgs> on_deactivate { get; set; }
- public ControlAction<EventArgs> on_closed { get; set; }
- public ControlAction<CancelEventArgs> on_closing { get; set; }
+ public ControlAction<EventArgs> activated { get; set; }
+ public ControlAction<EventArgs> deactivated { get; set; }
+ public ControlAction<EventArgs> closed { get; set; }
+ public ControlAction<CancelEventArgs> closing { get; set; }
public IApplicationDockedWindow create_tool_tip_for(string title, string caption, Control control)
{
trunk/product/MoMoney.Presentation/Views/Core/ApplicationWindow.cs
@@ -4,6 +4,7 @@ using System.Windows.Forms;
using Gorilla.Commons.Windows.Forms;
using Gorilla.Commons.Windows.Forms.Helpers;
using MoMoney.Presentation.Resources;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.core
{
@@ -23,16 +24,16 @@ namespace MoMoney.Presentation.Views.core
Icon = ApplicationIcons.Application;
//this.log().debug("created {0}", GetType());
- on_activated = x => { };
- on_deactivate = x => { };
- on_closed = x => { };
- on_closing = x => { };
+ activated = x => { };
+ deactivated = x => { };
+ closed = x => { };
+ closing = x => { };
}
- public ControlAction<EventArgs> on_activated { get; set; }
- public ControlAction<EventArgs> on_deactivate { get; set; }
- public ControlAction<EventArgs> on_closed { get; set; }
- public ControlAction<CancelEventArgs> on_closing { get; set; }
+ public ControlAction<EventArgs> activated { get; set; }
+ public ControlAction<EventArgs> deactivated { get; set; }
+ public ControlAction<EventArgs> closed { get; set; }
+ public ControlAction<CancelEventArgs> closing { get; set; }
public IApplicationWindow create_tool_tip_for(string title, string caption, Control control)
{
@@ -66,25 +67,25 @@ namespace MoMoney.Presentation.Views.core
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
- on_activated(e);
+ activated(e);
}
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
- on_deactivate(e);
+ deactivated(e);
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
- on_closing(e);
+ closing(e);
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
- on_closed(e);
+ closed(e);
}
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Views/Core/IDockedContentView.cs
@@ -1,16 +1,9 @@
-using Gorilla.Commons.Windows.Forms;
-using MoMoney.Presentation.Core;
using WeifenLuo.WinFormsUI.Docking;
-namespace MoMoney.Presentation.Views.core
+namespace MoMoney.Presentation.Views.Core
{
public interface IDockedContentView : IDockContent, IView
{
void add_to(DockPanel panel);
}
-
- public interface IView<Presenter> : IView where Presenter : IPresenter
- {
- void attach_to(Presenter presenter);
- }
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Views/Core/IView.cs
@@ -1,9 +1,15 @@
using System;
using System.ComponentModel;
+using MoMoney.Presentation.Core;
-namespace Gorilla.Commons.Windows.Forms
+namespace MoMoney.Presentation.Views.Core
{
public interface IView : IWindowEvents, ISynchronizeInvoke, IDisposable
{
}
+
+ public interface IView<TPresenter> : IView where TPresenter : IPresenter
+ {
+ void attach_to(TPresenter presenter);
+ }
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Views/Core/IWindowEvents.cs
@@ -1,13 +1,14 @@
using System;
using System.ComponentModel;
+using Gorilla.Commons.Windows.Forms;
-namespace Gorilla.Commons.Windows.Forms
+namespace MoMoney.Presentation.Views.Core
{
public interface IWindowEvents
{
- ControlAction<EventArgs> on_activated { get; set; }
- ControlAction<EventArgs> on_deactivate { get; set; }
- ControlAction<EventArgs> on_closed { get; set; }
- ControlAction<CancelEventArgs> on_closing { get; set; }
+ ControlAction<EventArgs> activated { get; set; }
+ ControlAction<EventArgs> deactivated { get; set; }
+ ControlAction<EventArgs> closed { get; set; }
+ ControlAction<CancelEventArgs> closing { get; set; }
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Views/Dialogs/ISaveChangesView.cs
@@ -1,5 +1,5 @@
using MoMoney.Presentation.Model.Menu.File.Commands;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.dialogs
{
trunk/product/MoMoney.Presentation/Views/Income/AddNewIncomeView.cs
@@ -1,27 +1,29 @@
using System;
using System.Collections.Generic;
-using System.Text;
using System.Windows.Forms;
using Gorilla.Commons.Utility.Extensions;
using Gorilla.Commons.Windows.Forms;
+using Gorilla.Commons.Windows.Forms.Helpers;
using Gorilla.Commons.Windows.Forms.Krypton;
using MoMoney.DTO;
using MoMoney.Presentation.Presenters.income;
using MoMoney.Presentation.Presenters.income.dto;
using MoMoney.Presentation.Views.core;
-using MoMoney.Service.Application;
namespace MoMoney.Presentation.Views.income
{
public partial class AddNewIncomeView : ApplicationDockedWindow, IAddNewIncomeView
{
ControlAction<EventArgs> submit_button = x => { };
+ readonly IBindableList<CompanyDTO> companies_list;
public AddNewIncomeView()
{
InitializeComponent();
titled("Add Income");
ux_submit_button.Click += (sender, e) => submit_button(e);
+
+ companies_list = ux_companys.create_for<CompanyDTO>();
}
public void attach_to(IAddNewIncomePresenter presenter)
@@ -31,7 +33,8 @@ namespace MoMoney.Presentation.Views.income
public void run(IEnumerable<CompanyDTO> companies)
{
- ux_companys.bind_to(companies);
+ companies_list.bind_to(companies);
+ //ux_companys.bind_to(companies);
}
public void run(IEnumerable<IncomeInformationDTO> incomes)
@@ -39,18 +42,11 @@ namespace MoMoney.Presentation.Views.income
ux_income_received_grid.DataSource = incomes.databind();
}
- public void notify(params NotificationMessage[] messages)
- {
- var builder = new StringBuilder();
- messages.each(x => builder.AppendLine(x));
- MessageBox.Show(builder.ToString(), "Ooops...", MessageBoxButtons.OK);
- }
-
IncomeSubmissionDto create_income()
{
return new IncomeSubmissionDto
{
- company_id = ux_companys.SelectedItem.downcast_to<CompanyDTO>().id,
+ company_id = companies_list.get_selected_item().id,
amount = ux_amount.Text.to_double(),
recieved_date = ux_date_received.Value
};
trunk/product/MoMoney.Presentation/Views/Income/IAddNewIncomeView.cs
@@ -1,14 +1,14 @@
using System.Collections.Generic;
using Gorilla.Commons.Utility.Core;
using MoMoney.DTO;
-using MoMoney.Presentation.Model.interaction;
using MoMoney.Presentation.Presenters.income;
using MoMoney.Presentation.Presenters.income.dto;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.income
{
- public interface IAddNewIncomeView : IDockedContentView, IView<IAddNewIncomePresenter>, INotification,
+ public interface IAddNewIncomeView : IDockedContentView,
+ IView<IAddNewIncomePresenter>,
ICallback<IEnumerable<CompanyDTO>>,
ICallback<IEnumerable<IncomeInformationDTO>>
{
trunk/product/MoMoney.Presentation/Views/Income/IViewIncomeHistory.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
using Gorilla.Commons.Utility.Core;
using MoMoney.Presentation.Presenters.income;
using MoMoney.Presentation.Presenters.income.dto;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.income
{
trunk/product/MoMoney.Presentation/Views/Menu/IAboutApplicationView.cs
@@ -1,6 +1,6 @@
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
-namespace MoMoney.Presentation.Views.Menu.Help
+namespace MoMoney.Presentation.Views.Menu
{
public interface IAboutApplicationView : IDockedContentView
{
trunk/product/MoMoney.Presentation/Views/Reporting/IReportViewer.cs
@@ -1,5 +1,5 @@
using MoMoney.Presentation.Model.reporting;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.reporting
{
trunk/product/MoMoney.Presentation/Views/Shell/ApplicationShell.cs
@@ -7,8 +7,8 @@ using Gorilla.Commons.Utility.Extensions;
using Gorilla.Commons.Windows.Forms;
using Gorilla.Commons.Windows.Forms.Helpers;
using MoMoney.Presentation.Presenters.Shell;
-using MoMoney.Presentation.Resources;
using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.Shell
{
trunk/product/MoMoney.Presentation/Views/Shell/IGettingStartedView.cs
@@ -1,5 +1,5 @@
using MoMoney.Presentation.Presenters.Shell;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.Shell
{
trunk/product/MoMoney.Presentation/Views/Shell/ILogFileView.cs
@@ -1,5 +1,5 @@
using Gorilla.Commons.Utility.Core;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.Shell
{
trunk/product/MoMoney.Presentation/Views/Shell/IShell.cs
@@ -2,7 +2,7 @@ using System;
using System.ComponentModel;
using System.Windows.Forms;
using MoMoney.Presentation.Presenters.Shell;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.Shell
{
trunk/product/MoMoney.Presentation/Views/Shell/IUnhandledErrorView.cs
@@ -1,6 +1,6 @@
using System;
using MoMoney.Presentation.Presenters.Shell;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.Shell
{
trunk/product/MoMoney.Presentation/Views/Updates/ICheckForUpdatesView.cs
@@ -2,7 +2,7 @@ using Gorilla.Commons.Utility;
using Gorilla.Commons.Utility.Core;
using MoMoney.Presentation.Model.updates;
using MoMoney.Presentation.Presenters.updates;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views.updates
{
trunk/product/MoMoney.Presentation/Views/AddCompanyView.cs
@@ -47,12 +47,5 @@ namespace MoMoney.Presentation.Views
listView1.Items.Clear();
listView1.Items.AddRange(companies.Select(x => new ListViewItem(x.name, 0)).ToArray());
}
-
- public void notify(params NotificationMessage[] messages)
- {
- var builder = new StringBuilder();
- messages.each(x => builder.Append(x));
- MessageBox.Show(builder.ToString());
- }
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Views/IAddCompanyView.cs
@@ -1,15 +1,14 @@
using System.Collections.Generic;
using Gorilla.Commons.Utility.Core;
using MoMoney.DTO;
-using MoMoney.Presentation.Model.interaction;
using MoMoney.Presentation.Presenters;
-using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Core;
namespace MoMoney.Presentation.Views
{
- public interface IAddCompanyView : IDockedContentView, INotification, IView<IAddCompanyPresenter>,
+ public interface IAddCompanyView : IDockedContentView,
+ IView<IAddCompanyPresenter>,
ICallback<IEnumerable<CompanyDTO>>
{
- //void run(IEnumerable<ICompany> companies);
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/MoMoney.Presentation.csproj
@@ -191,6 +191,7 @@
<Compile Include="Presenters\Shell\LogFileViewPresenterSpecs.cs" />
<Compile Include="Presenters\Shell\NotificationIconPresenter.cs" />
<Compile Include="Presenters\Shell\NotificationIconPresenterSpecs.cs" />
+ <Compile Include="Presenters\Shell\NotificationPresenter.cs" />
<Compile Include="Presenters\Shell\StatusBarPresenter.cs" />
<Compile Include="Presenters\Shell\StatusBarPresenterSpecs.cs" />
<Compile Include="Presenters\Shell\TaskTrayPresenter.cs" />
@@ -443,10 +444,6 @@
<Project>{54B55B2B-A58F-45DF-A446-234C9D70DC0B}</Project>
<Name>Gorilla.Commons.Windows.Forms</Name>
</ProjectReference>
- <ProjectReference Include="..\MoMoney.DataAccess\MoMoney.DataAccess.csproj">
- <Project>{580E68A8-EDEE-4350-8BBE-A053645B0F83}</Project>
- <Name>MoMoney.DataAccess</Name>
- </ProjectReference>
<ProjectReference Include="..\MoMoney.DTO\MoMoney.DTO.csproj">
<Project>{ACF52FAB-435B-48C9-A383-C787CB2D8000}</Project>
<Name>MoMoney.DTO</Name>
trunk/product/MoMoney.Service/Application/AddNewIncomeCommand.cs
@@ -2,9 +2,8 @@ using System.Linq;
using Gorilla.Commons.Utility.Core;
using Gorilla.Commons.Utility.Extensions;
using MoMoney.Domain.Core;
-using MoMoney.Presentation.Model.interaction;
-using MoMoney.Presentation.Presenters.income.dto;
-using MoMoney.Tasks.application;
+using MoMoney.Domain.repositories;
+using MoMoney.DTO;
namespace MoMoney.Service.Application
{
@@ -14,13 +13,17 @@ namespace MoMoney.Service.Application
public class AddNewIncomeCommand : IAddNewIncomeCommand
{
- readonly IIncomeTasks tasks;
+ readonly ICustomerTasks tasks;
readonly INotification notification;
+ readonly IIncomeRepository all_income;
+ readonly ICompanyRepository companys;
- public AddNewIncomeCommand(IIncomeTasks tasks, INotification notification)
+ public AddNewIncomeCommand(ICustomerTasks tasks, INotification notification, IIncomeRepository all_income,ICompanyRepository companys)
{
this.tasks = tasks;
this.notification = notification;
+ this.all_income = all_income;
+ this.companys = companys;
}
public void run(IncomeSubmissionDto item)
@@ -29,14 +32,23 @@ namespace MoMoney.Service.Application
{
notification.notify("You have already submitted this income");
}
- tasks.add_new(item);
+ else
+ {
+ companys
+ .find_company_by(item.company_id)
+ .pay(
+ tasks.get_the_current_customer(),
+ item.amount.as_money(),
+ item.recieved_date.as_a_date()
+ );
+ }
}
bool similar_income_has_been_submitted(IncomeSubmissionDto income)
{
- if (tasks.retrive_all_income().Count() == 0) return false;
- return tasks
- .retrive_all_income()
+ if (all_income.all().Count() == 0) return false;
+ return all_income
+ .all()
.where(x => x.amount_tendered.Equals(income.amount.as_money()))
.where(x => x.company.id.Equals(income.company_id))
.where(x => x.date_of_issue.Equals(income.recieved_date.as_a_date()))
trunk/product/MoMoney.Service/Application/AddNewIncomeCommandSpecs.cs
@@ -5,9 +5,8 @@ using Gorilla.Commons.Utility;
using MoMoney.Domain.accounting.billing;
using MoMoney.Domain.Accounting.Growth;
using MoMoney.Domain.Core;
-using MoMoney.Presentation.Model.interaction;
-using MoMoney.Presentation.Presenters.income.dto;
-using MoMoney.Tasks.application;
+using MoMoney.Domain.repositories;
+using MoMoney.DTO;
namespace MoMoney.Service.Application
{
@@ -21,11 +20,15 @@ namespace MoMoney.Service.Application
context c = () =>
{
notification = the_dependency<INotification>();
- tasks = the_dependency<IIncomeTasks>();
+ tasks = the_dependency<ICustomerTasks>();
+ all_income = the_dependency<IIncomeRepository>();
+ companies = the_dependency<ICompanyRepository>();
};
static protected INotification notification;
- static protected IIncomeTasks tasks;
+ static protected ICustomerTasks tasks;
+ static protected IIncomeRepository all_income;
+ static protected ICompanyRepository companies;
}
[Concern(typeof (AddNewIncomeCommand))]
@@ -52,7 +55,7 @@ namespace MoMoney.Service.Application
when_the(matching_income).is_asked_for(x => x.company).it_will_return(a_company);
when_the(matching_income).is_asked_for(x => x.date_of_issue).it_will_return(today);
when_the(a_company).is_asked_for(x => x.id).it_will_return(id);
- when_the(tasks).is_told_to(x => x.retrive_all_income()).it_will_return(matching_income);
+ when_the(all_income).is_told_to(x => x.all()).it_will_return(matching_income);
};
because b = () => sut.run(income);
trunk/product/MoMoney.Service/Application/BillingTasks.cs
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using MoMoney.Domain.accounting.billing;
-using MoMoney.Domain.repositories;
-
-namespace MoMoney.Tasks.application
-{
- public interface IBillingTasks
- {
- IEnumerable<IBill> all_bills();
- IEnumerable<ICompany> all_companys();
- }
-
- public class BillingTasks : IBillingTasks
- {
- readonly IBillRepository bills;
- readonly ICompanyRepository companys;
-
- public BillingTasks(IBillRepository bills, ICompanyRepository companys)
- {
- this.bills = bills;
- this.companys = companys;
- }
-
- public IEnumerable<IBill> all_bills()
- {
- return bills.all();
- }
-
- public IEnumerable<ICompany> all_companys()
- {
- return companys.all();
- }
- }
-}
\ No newline at end of file
trunk/product/MoMoney.Service/Application/CustomerTasks.cs
@@ -2,7 +2,7 @@ using System.Linq;
using MoMoney.Domain.accounting;
using MoMoney.Domain.repositories;
-namespace MoMoney.Tasks.application
+namespace MoMoney.Service.Application
{
public interface ICustomerTasks
{
@@ -11,7 +11,7 @@ namespace MoMoney.Tasks.application
public class CustomerTasks : ICustomerTasks
{
- IAccountHolderRepository account_holders;
+ readonly IAccountHolderRepository account_holders;
public CustomerTasks(IAccountHolderRepository account_holders)
{
trunk/product/MoMoney.Service/Application/GetAllIncomeQuery.cs
@@ -2,8 +2,8 @@ using System.Collections.Generic;
using Gorilla.Commons.Utility.Core;
using Gorilla.Commons.Utility.Extensions;
using MoMoney.Domain.Accounting.Growth;
+using MoMoney.Domain.repositories;
using MoMoney.Presentation.Presenters.income.dto;
-using MoMoney.Tasks.application;
namespace MoMoney.Service.Application
{
@@ -13,16 +13,16 @@ namespace MoMoney.Service.Application
public class GetAllIncomeQuery : IGetAllIncomeQuery
{
- readonly IIncomeTasks tasks;
+ readonly IIncomeRepository all_income;
- public GetAllIncomeQuery(IIncomeTasks tasks)
+ public GetAllIncomeQuery(IIncomeRepository all_income)
{
- this.tasks = tasks;
+ this.all_income = all_income;
}
public IEnumerable<IncomeInformationDTO> fetch()
{
- return tasks.retrive_all_income().map_all_using(x => map_from(x));
+ return all_income.all().map_all_using(x => map_from(x));
}
static IncomeInformationDTO map_from(IIncome x)
trunk/product/MoMoney.Service/Application/IncomeTasks.cs
@@ -1,50 +0,0 @@
-using System.Collections.Generic;
-using MoMoney.Domain.accounting.billing;
-using MoMoney.Domain.Accounting.Growth;
-using MoMoney.Domain.Core;
-using MoMoney.Domain.repositories;
-using MoMoney.Presentation.Presenters.income.dto;
-
-namespace MoMoney.Tasks.application
-{
- public interface IIncomeTasks
- {
- void add_new(IncomeSubmissionDto income);
- IEnumerable<ICompany> all_companys();
- IEnumerable<IIncome> retrive_all_income();
- }
-
- public class IncomeTasks : IIncomeTasks
- {
- readonly ICustomerTasks tasks;
- readonly ICompanyRepository companys;
- readonly IIncomeRepository incomes;
-
- public IncomeTasks(ICustomerTasks tasks, ICompanyRepository companys, IIncomeRepository incomes)
- {
- this.incomes = incomes;
- this.companys = companys;
- this.tasks = tasks;
- }
-
- public void add_new(IncomeSubmissionDto income)
- {
- var company = companys.find_company_by(income.company_id);
- company.pay(
- tasks.get_the_current_customer(),
- income.amount.as_money(),
- income.recieved_date.as_a_date()
- );
- }
-
- public IEnumerable<ICompany> all_companys()
- {
- return companys.all();
- }
-
- public IEnumerable<IIncome> retrive_all_income()
- {
- return incomes.all();
- }
- }
-}
\ No newline at end of file
trunk/product/MoMoney.Service/Application/INotification.cs
@@ -1,6 +1,4 @@
-using MoMoney.Service.Application;
-
-namespace MoMoney.Presentation.Model.interaction
+namespace MoMoney.Service.Application
{
public interface INotification
{
trunk/product/MoMoney.Service/Application/RegisterNewCompanyCommand.cs
@@ -1,5 +1,8 @@
+using System.Linq;
using Gorilla.Commons.Utility.Core;
+using Gorilla.Commons.Utility.Extensions;
using MoMoney.Domain.accounting.billing;
+using MoMoney.Domain.repositories;
using MoMoney.DTO;
namespace MoMoney.Service.Application
@@ -11,15 +14,32 @@ namespace MoMoney.Service.Application
public class RegisterNewCompanyCommand : IRegisterNewCompanyCommand
{
readonly ICompanyFactory factory;
+ readonly INotification notification;
+ readonly ICompanyRepository companies;
- public RegisterNewCompanyCommand(ICompanyFactory factory)
+ public RegisterNewCompanyCommand(ICompanyFactory factory, INotification notification, ICompanyRepository companies)
{
this.factory = factory;
+ this.notification = notification;
+ this.companies = companies;
}
public void run(RegisterNewCompany item)
{
- factory.create().change_name_to(item.company_name);
+ if (company_has_already_been_registered(item))
+ notification.notify(create_error_message_from(item));
+ else
+ factory.create().change_name_to(item.company_name);
+ }
+
+ bool company_has_already_been_registered(RegisterNewCompany dto)
+ {
+ return companies.all().Count(x => x.name.is_equal_to_ignoring_case(dto.company_name)) > 0;
+ }
+
+ string create_error_message_from(RegisterNewCompany dto)
+ {
+ return "A Company named {0}, has already been submitted!".formatted_using(dto.company_name);
}
}
}
\ No newline at end of file
trunk/product/MoMoney.Service/Application/SaveNewBillCommand.cs
@@ -2,6 +2,7 @@ using Gorilla.Commons.Utility.Core;
using MoMoney.Domain.Core;
using MoMoney.Domain.repositories;
using MoMoney.Presentation.Presenters.billing.dto;
+using MoMoney.Service.Application;
namespace MoMoney.Tasks.application
{
trunk/product/MoMoney.Service/Infrastructure/ProjectTasks.cs
@@ -0,0 +1,37 @@
+using Gorilla.Commons.Infrastructure.FileSystem;
+using MoMoney.DataAccess;
+
+namespace MoMoney.Service.Infrastructure
+{
+ public interface IProjectTasks
+ {
+ void open(IFile file);
+ void copy_to(string path);
+ void close(string path);
+ }
+
+ public class ProjectTasks : IProjectTasks
+ {
+ readonly IDatabaseConfiguration configuration;
+
+ public ProjectTasks(IDatabaseConfiguration configuration)
+ {
+ this.configuration = configuration;
+ }
+
+ public void open(IFile file)
+ {
+ configuration.open(file);
+ }
+
+ public void copy_to(string path)
+ {
+ configuration.copy_to(path);
+ }
+
+ public void close(string path)
+ {
+ configuration.close(path);
+ }
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Service/MoMoney.Service.csproj
@@ -60,17 +60,16 @@
<ItemGroup>
<Compile Include="Application\AddNewIncomeCommand.cs" />
<Compile Include="Application\AddNewIncomeCommandSpecs.cs" />
- <Compile Include="Application\BillingTasks.cs" />
<Compile Include="Application\CustomerTasks.cs" />
<Compile Include="Application\GetAllBillsQuery.cs" />
<Compile Include="Application\GetAllCompanysQuery.cs" />
<Compile Include="Application\GetAllIncomeQuery.cs" />
- <Compile Include="Application\IncomeTasks.cs" />
<Compile Include="Application\INotification.cs" />
<Compile Include="Application\NotificationMessage.cs" />
<Compile Include="Application\RegisterNewCompanyCommand.cs" />
<Compile Include="Application\SaveNewBillCommand.cs" />
<Compile Include="Infrastructure\Logging\LogFileTasks.cs" />
+ <Compile Include="Infrastructure\ProjectTasks.cs" />
<Compile Include="Infrastructure\Updating\CancelUpdate.cs" />
<Compile Include="Infrastructure\Updating\CancelUpdateSpecs.cs" />
<Compile Include="Infrastructure\Updating\CurrentDeployment.cs" />
trunk/product/MyMoney/boot/container/registration/wire_up_the_infrastructure_in_to_the.cs
@@ -26,7 +26,7 @@ namespace MoMoney.boot.container.registration
registry.transient(typeof (IRegistry<>), typeof (DefaultRegistry<>));
registry.transient(typeof (ITrackerEntryMapper<>), typeof (TrackerEntryMapper<>));
registry.transient(typeof(IKey<>), typeof(TypedKey<>));
- registry.transient(typeof (IComponentFactory<>), typeof (Factory<>));
+ registry.transient(typeof (IComponentFactory<>), typeof (ComponentFactory<>));
registry.singleton<IContext, Context>();
}
}
trunk/product/MyMoney/boot/container/registration/wire_up_the_services_in_to_the.cs
@@ -20,17 +20,9 @@ namespace MoMoney.boot.container.registration
public void run()
{
- registry.proxy<IBillingTasks, ServiceLayerConfiguration<IBillingTasks>>(
- () => new BillingTasks(Lazy.load<IBillRepository>(), Lazy.load<ICompanyRepository>()));
-
registry.proxy<ICustomerTasks, ServiceLayerConfiguration<ICustomerTasks>>(
() => new CustomerTasks(Lazy.load<IAccountHolderRepository>()));
- registry.proxy<IIncomeTasks, ServiceLayerConfiguration<IIncomeTasks>>(
- () => new IncomeTasks(Lazy.load<ICustomerTasks>(),
- Lazy.load<ICompanyRepository>(),
- Lazy.load<IIncomeRepository>()));
-
wire_up_queries();
wire_up_the_commands();
}
@@ -46,7 +38,7 @@ namespace MoMoney.boot.container.registration
void wire_up_the_commands()
{
registry.proxy<IRegisterNewCompanyCommand, ServiceLayerConfiguration<IRegisterNewCompanyCommand>>(
- () => new RegisterNewCompanyCommand(Lazy.load<ICompanyFactory>()));
+ () => new RegisterNewCompanyCommand(Lazy.load<ICompanyFactory>(),Lazy.load<INotification>(),Lazy.load<ICompanyRepository>()));
registry.proxy<ISaveNewBillCommand, ServiceLayerConfiguration<ISaveNewBillCommand>>(
() => new SaveNewBillCommand(Lazy.load<ICompanyRepository>(), Lazy.load<ICustomerTasks>()));
}
trunk/product/MyMoney/boot/container/registration/wire_up_the_views_in_to_the.cs
@@ -6,6 +6,7 @@ using MoMoney.Presentation.Views;
using MoMoney.Presentation.Views.billing;
using MoMoney.Presentation.Views.dialogs;
using MoMoney.Presentation.Views.income;
+using MoMoney.Presentation.Views.Menu;
using MoMoney.Presentation.Views.Menu.Help;
using MoMoney.Presentation.Views.Navigation;
using MoMoney.Presentation.Views.Shell;