diff --git a/Moonlight/App/Services/IdentityService.cs b/Moonlight/App/Services/IdentityService.cs index a333919..c31b303 100644 --- a/Moonlight/App/Services/IdentityService.cs +++ b/Moonlight/App/Services/IdentityService.cs @@ -1,4 +1,6 @@ -using Moonlight.App.Database.Entities; +using Microsoft.EntityFrameworkCore; +using Moonlight.App.Database.Entities; +using Moonlight.App.Database.Entities.Store; using Moonlight.App.Exceptions; using Moonlight.App.Helpers; using Moonlight.App.Models.Abstractions; @@ -23,6 +25,7 @@ public class IdentityService public bool IsSignedIn => CurrentUserNullable != null; public FlagStorage Flags { get; private set; } = new(""); public PermissionStorage Permissions { get; private set; } = new(-1); + public Transaction[] Transactions => GetTransactions().Result; // TODO: make more efficient public EventHandler OnAuthenticationStateChanged { get; set; } public IdentityService(Repository userRepository, @@ -31,6 +34,20 @@ public class IdentityService UserRepository = userRepository; JwtService = jwtService; } + + // Transactions + public Task GetTransactions() + { + if (CurrentUserNullable == null) + return Task.FromResult(Array.Empty()); + + var user = UserRepository + .Get() + .Include(x => x.Transactions) + .First(x => x.Id == CurrentUserNullable.Id); + + return Task.FromResult(user.Transactions.ToArray()); + } // Authentication diff --git a/Moonlight/Shared/Components/Navigations/AccountNavigation.razor b/Moonlight/Shared/Components/Navigations/AccountNavigation.razor index 396283d..d3ed097 100644 --- a/Moonlight/Shared/Components/Navigations/AccountNavigation.razor +++ b/Moonlight/Shared/Components/Navigations/AccountNavigation.razor @@ -1,4 +1,4 @@ -
+
diff --git a/Moonlight/Shared/Views/Account/Payments.razor b/Moonlight/Shared/Views/Account/Payments.razor new file mode 100644 index 0000000..e154bf2 --- /dev/null +++ b/Moonlight/Shared/Views/Account/Payments.razor @@ -0,0 +1,55 @@ +@page "/account/payments" + +@using Moonlight.App.Services +@using Moonlight.App.Database.Entities.Store +@using BlazorTable + +@inject IdentityService IdentityService +@inject ConfigService ConfigService + + + +
+
+

Transactions

+
+
+ + + + + + + + + + +
+
+
+
+ +@code +{ + private Transaction[] Transactions; + + private async Task Load(LazyLoader _) + { + Transactions = await IdentityService.GetTransactions(); + } +} \ No newline at end of file