Commit db622b7
Changed files (9)
product
desktop.ui
bootstrappers
messages
model
views
product/desktop.ui/bootstrappers/ConfigureMappings.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using desktop.ui.handlers.domain;
+using desktop.ui.model;
using desktop.ui.presenters;
using gorilla.utility;
product/desktop.ui/messages/private/AddedNewFamilyMember.cs
@@ -0,0 +1,12 @@
+using System;
+using desktop.ui.eventing;
+
+namespace desktop.ui.presenters
+{
+ public class AddedNewFamilyMember : Event
+ {
+ public Guid id { get; set; }
+ public string first_name { get; set; }
+ public string last_name { get; set; }
+ }
+}
\ No newline at end of file
product/desktop.ui/messages/private/FindAllFamily.cs
@@ -0,0 +1,6 @@
+namespace desktop.ui.presenters
+{
+ public class FindAllFamily
+ {
+ }
+}
\ No newline at end of file
product/desktop.ui/presenters/PersonDetails.cs → product/desktop.ui/model/PersonDetails.cs
@@ -1,7 +1,7 @@
using System;
using gorilla.utility;
-namespace desktop.ui.presenters
+namespace desktop.ui.model
{
public class PersonDetails
{
product/desktop.ui/presenters/SelectedFamilyMemberPresenter.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using desktop.ui.eventing;
using desktop.ui.events;
+using desktop.ui.model;
using gorilla.utility;
namespace desktop.ui.presenters
@@ -47,14 +48,4 @@ namespace desktop.ui.presenters
}
}
- public class FindAllFamily
- {
- }
-
- public class AddedNewFamilyMember : Event
- {
- public Guid id { get; set; }
- public string first_name { get; set; }
- public string last_name { get; set; }
- }
}
\ No newline at end of file
product/desktop.ui/presenters/TaxSummaryPresenter.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using desktop.ui.eventing;
using desktop.ui.events;
@@ -8,7 +9,6 @@ namespace desktop.ui.presenters
EventSubscriber<AddIncomeCommandMessage>, EventSubscriber<SelectedFamilyMember>
{
UICommandBuilder builder;
- Guid person_id;
public TaxSummaryPresenter(UICommandBuilder builder)
{
@@ -24,34 +24,46 @@ namespace desktop.ui.presenters
get { return "Taxes"; }
}
- public decimal TotalIncome { get; set; }
- public decimal Taxes { get; set; }
+ public TaxesForIndividual Selected { get; set; }
public void notify(AddIncomeCommandMessage message)
{
- TotalIncome += message.amount;
- if(TotalIncome <= 41544.00m)
+ Selected.TotalIncome += message.amount;
+ if (Selected.TotalIncome <= 41544.00m)
{
- Taxes = ((TotalIncome - 0m)*0.15m) + 0m;
+ Selected.Taxes = ((Selected.TotalIncome - 0m)*0.15m) + 0m;
}
- if (TotalIncome > 41544.00m && TotalIncome <= 83088.00m)
+ if (Selected.TotalIncome > 41544.00m && Selected.TotalIncome <= 83088.00m)
{
- Taxes = ((TotalIncome - 41544m)*0.22m) + 6232m;
+ Selected.Taxes = ((Selected.TotalIncome - 41544m)*0.22m) + 6232m;
}
- if(TotalIncome > 83088.00m && TotalIncome <= 128800.00m)
+ if (Selected.TotalIncome > 83088.00m && Selected.TotalIncome <= 128800.00m)
{
- Taxes = ((TotalIncome - 83088m)*0.26m) + 15371m;
+ Selected.Taxes = ((Selected.TotalIncome - 83088m)*0.26m) + 15371m;
}
- if(TotalIncome > 128800.00m)
+ if (Selected.TotalIncome > 128800.00m)
{
- Taxes = ((TotalIncome - 128800m)*0.29m) + 27256m;
+ Selected.Taxes = ((Selected.TotalIncome - 128800m)*0.29m) + 27256m;
}
- update(x => x.Taxes, x => x.TotalIncome);
+ Selected.update(x => x.Taxes, x => x.TotalIncome);
}
public void notify(SelectedFamilyMember message)
{
- person_id = message.id;
+ if (!people.ContainsKey(message.id))
+ {
+ people[message.id] = new TaxesForIndividual();
+ }
+ Selected = people[message.id];
+ update(x => x.Selected);
}
+
+ IDictionary<Guid, TaxesForIndividual> people = new Dictionary<Guid, TaxesForIndividual>();
+ }
+
+ public class TaxesForIndividual : Observable<TaxesForIndividual>
+ {
+ public decimal TotalIncome { get; set; }
+ public decimal Taxes { get; set; }
}
}
\ No newline at end of file
product/desktop.ui/views/TaxSummaryTab.xaml
@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
- <StackPanel>
+ <StackPanel DataContext="{Binding Path=Selected}">
<Label>Tax Summary</Label>
<Label>Federal Tax Rates for 2011</Label>
<TextBlock>
product/desktop.ui/desktop.ui.csproj
@@ -89,13 +89,15 @@
<Compile Include="handlers\orm\PersonRepository.cs" />
<Compile Include="handlers\PublishEventHandler.cs" />
<Compile Include="IObservableCommand.cs" />
+ <Compile Include="messages\private\AddedNewFamilyMember.cs" />
<Compile Include="Observable.cs" />
<Compile Include="Presenter.cs" />
<Compile Include="PresenterFactory.cs" />
<Compile Include="presenters\AddFamilyMemberPresenter.cs" />
<Compile Include="presenters\AddNewIncomeViewModel.cs" />
<Compile Include="presenters\DisplayCanadianTaxInformationViewModel.cs" />
- <Compile Include="presenters\PersonDetails.cs" />
+ <Compile Include="messages\private\FindAllFamily.cs" />
+ <Compile Include="model\PersonDetails.cs" />
<Compile Include="presenters\SelectedFamilyMemberPresenter.cs" />
<Compile Include="presenters\TaxSummaryPresenter.cs" />
<Compile Include="ServiceBus.cs" />
product/desktop.ui/Observable.cs
@@ -7,14 +7,28 @@ namespace desktop.ui
{
public abstract class Observable<T> : INotifyPropertyChanged
{
- public event PropertyChangedEventHandler PropertyChanged = (o, e) => {};
+ public event PropertyChangedEventHandler PropertyChanged = (o, e) => { };
- protected void update(params Expression<Func<T, object>>[] properties)
+ public void update(params Expression<Func<T, object>>[] properties)
{
- properties.each(x =>
+ properties.each(x => { PropertyChanged(this, new PropertyChangedEventArgs(x.pick_property().Name)); });
+ }
+ }
+
+ public class ObservableProperty<T> : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged = (o, e) => { };
+
+ public T Value
+ {
+ get { return value; }
+ set
{
- PropertyChanged(this, new PropertyChangedEventArgs(x.pick_property().Name));
- });
+ this.value = value;
+ PropertyChanged(this, new PropertyChangedEventArgs("Value"));
+ }
}
+
+ T value;
}
}
\ No newline at end of file