accounts = [];
+ private DateTime? SelectedValue;
+
+ protected override void OnInitialized()
+ {
+ SelectedValue = Content.ValueDate;
+ editContext = new EditContext(Content);
+ accounts = viewService.GetAccountViewList();
+ }
+
+ private async Task SaveAsync()
+ {
+ if (editContext.Validate())
+ {
+ Content.ValueDate = SelectedValue!.Value;
+ Content.BookingDate = SelectedValue!.Value;
+ transactionRepository.SaveTransaction(Content);
+ await Dialog.CloseAsync(Content);
+ }
+ }
+
+ private async Task CancelAsync()
+ {
+ await Dialog.CancelAsync();
+ }
+}
\ No newline at end of file
diff --git a/Schaad.Accounting.UI/Components/Pages/Transactions.razor b/Schaad.Accounting.UI/Components/Pages/Transactions.razor
index ad40e01..ddb84f6 100644
--- a/Schaad.Accounting.UI/Components/Pages/Transactions.razor
+++ b/Schaad.Accounting.UI/Components/Pages/Transactions.razor
@@ -17,7 +17,7 @@
- @account.BalanceCHF.ToString("C2")
+ @Math.Abs(account.BalanceCHF).ToString("C2")
@@ -29,21 +29,35 @@
-
-
-
-
-
-
+
+
+ @selectedAccount.Name
+
+
+ Total @Math.Abs(selectedAccount.Balance).ToString("C2") in @transactionList?.Count() Transaktionen
+
+
+ Neue Transaktion hinzufügen
+
+
+
+
+
+
+
+
@GetAccountName(context)
-
-
+
+
+
+
+
+
-
@code
diff --git a/Schaad.Accounting.UI/Components/Pages/Transactions.razor.cs b/Schaad.Accounting.UI/Components/Pages/Transactions.razor.cs
index 2e4f9a6..ed69ab1 100644
--- a/Schaad.Accounting.UI/Components/Pages/Transactions.razor.cs
+++ b/Schaad.Accounting.UI/Components/Pages/Transactions.razor.cs
@@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Components;
+using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Interfaces;
+using Schaad.Accounting.Models;
+using Schaad.Accounting.UI.Components.Pages.Dialogs;
namespace Schaad.Accounting.UI.Components.Pages;
@@ -8,21 +11,30 @@ public partial class Transactions : ComponentBase
{
[Inject]
private IViewService viewService { get; set; } = null!;
+
+ [Inject]
+ private ITransactionRepository transactionRepository { get; set; } = null!;
+
+ [Inject]
+ private IDialogService dialogService { get; set; } = null!;
private IReadOnlyList accounts = null!;
private IQueryable? transactionList;
- private string? selectedAccountId;
+ private string selectedAccountId = null!;
+ private AccountDataset selectedAccount = null!;
protected override Task OnInitializedAsync()
{
- accounts = viewService.GetAccountViewList();
- return base.OnInitializedAsync();
+ accounts = viewService.GetAccountViewList();
+ ShowTransactions(accounts.First().Id);
+ return base.OnInitializedAsync();
}
private void ShowTransactions(string accountId)
{
selectedAccountId = accountId;
+ selectedAccount = accounts.Single(a => a.Id == accountId);
transactionList = viewService.GetTransactionViewList(accountId).AsQueryable();
}
@@ -35,4 +47,57 @@ public partial class Transactions : ComponentBase
return transaction.OriginAccount.Name;
}
+
+ private async Task AddAsync()
+ {
+ var data = new Transaction
+ {
+ ValueDate = DateTime.Now,
+ BookingDate = DateTime.Now,
+ TargetAccountId = selectedAccountId
+ };
+ var dialog = await dialogService.ShowDialogAsync(data, new DialogParameters()
+ {
+ Height = "500px",
+ Title = "Transaktion",
+ PreventDismissOnOverlayClick = true,
+ PreventScroll = true,
+ });
+
+ var result = await dialog.Result;
+ if (!result.Cancelled && result.Data != null)
+ {
+ transactionList = viewService.GetTransactionViewList(selectedAccountId).AsQueryable();
+ }
+ }
+
+ private async Task EditAsync(string id)
+ {
+ var data = transactionRepository.GetTransaction(id);
+ var dialog = await dialogService.ShowDialogAsync(data, new DialogParameters()
+ {
+ Height = "500px",
+ Title = "Transaktion",
+ PreventDismissOnOverlayClick = true,
+ PreventScroll = true,
+ });
+
+ var result = await dialog.Result;
+ if (!result.Cancelled && result.Data != null)
+ {
+ transactionList = viewService.GetTransactionViewList(selectedAccountId).AsQueryable();
+ }
+ }
+
+ private async Task DeleteAsync(string id)
+ {
+ var transaction = transactionRepository.GetTransaction(id);
+ var dialog = await dialogService.ShowConfirmationAsync($"Transaction '{transaction.Text}' mit Betrag {transaction.Value} wirklich löschen?", "Ja", "Nein", "Transaktion löschen");
+ var result = await dialog.Result;
+ if (!result.Cancelled)
+ {
+ transactionRepository.DeleteTransaction(id);
+ transactionList = viewService.GetTransactionViewList(selectedAccountId).AsQueryable();
+ }
+ }
}
\ No newline at end of file
diff --git a/Schaad.Accounting.UI/Components/Pages/Transactions.razor.css b/Schaad.Accounting.UI/Components/Pages/Transactions.razor.css
new file mode 100644
index 0000000..2208e6b
--- /dev/null
+++ b/Schaad.Accounting.UI/Components/Pages/Transactions.razor.css
@@ -0,0 +1,3 @@
+.title {
+ font-size: 16pt;
+}
diff --git a/Schaad.Accounting.UI/Components/_Imports.razor b/Schaad.Accounting.UI/Components/_Imports.razor
index d5f412e..792f27f 100644
--- a/Schaad.Accounting.UI/Components/_Imports.razor
+++ b/Schaad.Accounting.UI/Components/_Imports.razor
@@ -1,6 +1,7 @@
@using System.ComponentModel.DataAnnotations
@using System.Net.Http
@using System.Net.Http.Json
+@using Microsoft.FluentUI.AspNetCore.Components.Extensions
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
diff --git a/Schaad.Accounting.UI/Schaad.Accounting.UI.csproj b/Schaad.Accounting.UI/Schaad.Accounting.UI.csproj
index cd0cc2a..2e84a9a 100644
--- a/Schaad.Accounting.UI/Schaad.Accounting.UI.csproj
+++ b/Schaad.Accounting.UI/Schaad.Accounting.UI.csproj
@@ -27,4 +27,9 @@
+
+
+
+
+