diff --git a/src/Money.Blazor.Host/Pages/Test.razor b/src/Money.Blazor.Host/Pages/Test.razor
index b33eb87b..2869bd8d 100644
--- a/src/Money.Blazor.Host/Pages/Test.razor
+++ b/src/Money.Blazor.Host/Pages/Test.razor
@@ -1,38 +1,37 @@
@page "/test"
+
+
- @if (Balances == null)
+ @if (ExpenseTemplates == null)
{
Loading...
}
else
{
-
-
- Month
- |
-
- Expenses
- |
-
- Incomes
- |
-
- @foreach (var balance in Balances)
+ @foreach (var expenseTemplate in ExpenseTemplates)
{
- @balance
+ @expenseTemplate.Key
+ |
+
+ @expenseTemplate.Amount
|
- @balance.ExpenseSummary
+ @expenseTemplate.Description
|
- @balance.IncomeSummary
+ @expenseTemplate.CategoryKey
+ |
+
+
|
}
+
+
}
\ No newline at end of file
diff --git a/src/Money.Blazor.Host/Pages/Test.razor.cs b/src/Money.Blazor.Host/Pages/Test.razor.cs
index d1ba2094..9d73ae91 100644
--- a/src/Money.Blazor.Host/Pages/Test.razor.cs
+++ b/src/Money.Blazor.Host/Pages/Test.razor.cs
@@ -3,6 +3,7 @@
using Money.Events;
using Money.Models;
using Money.Models.Queries;
+using Neptuo;
using Neptuo.Commands;
using Neptuo.Events;
using Neptuo.Events.Handlers;
@@ -17,7 +18,7 @@
namespace Money.Pages
{
- public partial class Test
+ public partial class Test : System.IDisposable, IEventHandler, IEventHandler
{
[Inject]
protected IQueryDispatcher Queries { get; set; }
@@ -28,13 +29,43 @@ public partial class Test
[Inject]
protected IEventHandlerCollection EventHandlers { get; set; }
- protected List Balances { get; set; }
+ protected List ExpenseTemplates { get; set; }
protected async override Task OnInitializedAsync()
{
await base.OnInitializedAsync();
+ await LoadAsync();
- Balances = await Queries.QueryAsync(new ListMonthBalance(DateTime.Now));
+ EventHandlers.Add(this);
+ EventHandlers.Add(this);
+ }
+
+ public void Dispose()
+ {
+ EventHandlers.Remove(this);
+ EventHandlers.Remove(this);
+ }
+
+ private async Task LoadAsync()
+ {
+ ExpenseTemplates = await Queries.QueryAsync(new ListAllExpenseTemplate());
+ }
+
+ protected async Task CreateAsync()
+ {
+ await Commands.HandleAsync(new CreateExpenseTemplate(new Price(2500, "CZK"), "2.5K", KeyFactory.Empty(typeof(Category))));
+ }
+
+ public async Task HandleAsync(ExpenseTemplateCreated payload)
+ {
+ await LoadAsync();
+ StateHasChanged();
+ }
+
+ public async Task HandleAsync(ExpenseTemplateDeleted payload)
+ {
+ await LoadAsync();
+ StateHasChanged();
}
}
}