-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement basic query and add (#65)
* refactor: move pages out of WASM project * refactor: move pages out of WASM project rebase main * rename bank into account * refactor: merge tiny modules into a single file * refactor: make folder structure more clear by grouping commands&queries by its function rather than its fields * feat: remove test queries in test.razor * feat: working on wallet.razor * fix * refactor: Code Format * refactor: Code cleanup * Rename * Refactor: Implement Dto patterns in all queries and commands * rename: Remove Command/Query from filename as the file contains all relevant stuff of the action * fix: File structural scoped namespace * feat: Wallet Page * feat: Add Transaction * refactor: merge tiny modules into a single file * refactor: make folder structure more clear by grouping commands&queries by its function rather than its fields * feat: remove test queries in test.razor * refactor: move pages out of WASM project rebase main * refactor: move pages out of WASM project * rename bank into account * feat: working on wallet.razor * fix * refactor: Code Format * refactor: Code cleanup * Rename * Refactor: Implement Dto patterns in all queries and commands * rename: Remove Command/Query from filename as the file contains all relevant stuff of the action * fix: File structural scoped namespace * feat: Wallet Page * feat: Add Transaction
- Loading branch information
1 parent
9e8d1e6
commit 3bb27e1
Showing
173 changed files
with
1,822 additions
and
1,654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/Backend/Accounts.Application/AccountService/AccountDto.cs
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/Backend/Accounts.Application/AccountService/Commands/CreateAccount.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Accounts.Domain.AccountAggregate; | ||
using Accounts.Domain.AccountAggregate.AccountEntity; | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Primitives; | ||
using Primitives.Command; | ||
|
||
namespace Accounts.Application.AccountService.Commands; | ||
|
||
public sealed class CreateAccountCommand( | ||
string description | ||
) : ICommandRequest<CreateAccountDto> | ||
{ | ||
public AccountDescription Description { get; } = new(description); | ||
} | ||
|
||
public record CreateAccountDto( | ||
long Id | ||
); | ||
|
||
[UsedImplicitly] | ||
internal sealed class CreateAccountCommandHandler( | ||
IAccountRepository accountRepository, | ||
[FromKeyedServices(key: "accounts")] IUnitOfWork unitOfWork | ||
) : ICommandRequestHandler<CreateAccountCommand, CreateAccountDto> | ||
{ | ||
public async Task<CreateAccountDto> Handle(CreateAccountCommand request, CancellationToken cancellationToken) | ||
{ | ||
var account = Account.CreateNewAccount(request.Description); | ||
var newId = await accountRepository.AddAccountAsync(account, cancellationToken); | ||
|
||
await unitOfWork.CommitChangesAsync(cancellationToken); | ||
return new CreateAccountDto(newId.Value); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Backend/Accounts.Application/AccountService/Commands/DeleteAccount.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Accounts.Domain.AccountAggregate.AccountEntity; | ||
|
||
namespace Accounts.Application.AccountService.Commands; | ||
|
||
public sealed class DeleteAccountCommand( | ||
long id | ||
) | ||
{ | ||
public AccountId Id { get; } = new(id); | ||
} |
9 changes: 0 additions & 9 deletions
9
src/Backend/Accounts.Application/AccountService/CreateAccount/CreateAccountCommand.cs
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/Backend/Accounts.Application/AccountService/CreateAccount/CreateAccountCommandHandler.cs
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/Backend/Accounts.Application/AccountService/CreateAccount/CreateAccountDto.cs
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/Backend/Accounts.Application/AccountService/DeleteAccount/DeleteAccountCommand.cs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
src/Backend/Accounts.Application/AccountService/GetAccounts/GetAccountsQuery.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/Backend/Accounts.Application/AccountService/GetAccounts/GetAccountsQueryHandler.cs
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/Backend/Accounts.Application/AccountService/GetAccounts/IGetAccountsRepository.cs
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
src/Backend/Accounts.Application/AccountService/Models/AccountModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Accounts.Application.AccountService.Models; | ||
|
||
public record AccountModel( | ||
long Id, | ||
string Description | ||
); |
27 changes: 27 additions & 0 deletions
27
src/Backend/Accounts.Application/AccountService/Queries/GetAccounts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Accounts.Application.AccountService.Models; | ||
using JetBrains.Annotations; | ||
using Primitives.Query; | ||
|
||
namespace Accounts.Application.AccountService.Queries; | ||
|
||
public sealed class GetAccountsQuery : IQueryRequest<GetAccountsDto> { } | ||
|
||
public record GetAccountsDto( | ||
IEnumerable<AccountModel> Accounts | ||
); | ||
|
||
public interface IGetAccountsRepository | ||
{ | ||
public Task<IEnumerable<AccountModel>> GetAccountsByAdminAsync(CancellationToken cancellationToken = default); | ||
} | ||
|
||
[UsedImplicitly] | ||
public sealed class GetAccountsQueryHandler( | ||
IGetAccountsRepository getAccountsRepository | ||
) : IQueryRequestHandler<GetAccountsQuery, GetAccountsDto> | ||
{ | ||
public async Task<GetAccountsDto> Handle(GetAccountsQuery request, CancellationToken cancellationToken) | ||
{ | ||
return new GetAccountsDto(await getAccountsRepository.GetAccountsByAdminAsync(cancellationToken)); | ||
} | ||
} |
33 changes: 21 additions & 12 deletions
33
src/Backend/Accounts.Application/Accounts.Application.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Shared\Exceptions\Exceptions.csproj" /> | ||
<ProjectReference Include="..\Accounts.Domain\Accounts.Domain.csproj" /> | ||
<ProjectReference Include="..\Accounts.IntegrationEvent\Accounts.IntegrationEvent.csproj" /> | ||
<ProjectReference Include="..\Asset.IntegrationEvent\Asset.IntegrationEvent.csproj" /> | ||
<ProjectReference Include="..\Budget.IntegrationEvent\Budget.IntegrationEvent.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\Shared\Exceptions\Exceptions.csproj"/> | ||
<ProjectReference Include="..\Accounts.Domain\Accounts.Domain.csproj"/> | ||
<ProjectReference Include="..\Accounts.IntegrationEvent\Accounts.IntegrationEvent.csproj"/> | ||
<ProjectReference Include="..\Asset.IntegrationEvent\Asset.IntegrationEvent.csproj"/> | ||
<ProjectReference Include="..\Budget.IntegrationEvent\Budget.IntegrationEvent.csproj"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="TagService\Commands\"/> | ||
<Folder Include="TagService\Queries\"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
6 changes: 6 additions & 0 deletions
6
src/Backend/Accounts.Application/TagService/Models/TagModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Accounts.Application.TagService.Models; | ||
|
||
public record TagModel( | ||
long TagId, | ||
string TagName | ||
); |
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/Backend/Accounts.Application/TestService/GetTest/TestQuery.cs
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
src/Backend/Accounts.Application/TestService/GetTest/TestQueryHandler.cs
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/Backend/Accounts.Application/TransactionService/AddTransaction/AddTransactionCommand.cs
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
...nd/Accounts.Application/TransactionService/AddTransaction/AddTransactionCommandHandler.cs
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/Backend/Accounts.Application/TransactionService/AddTransaction/AddTransactionDto.cs
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
src/Backend/Accounts.Application/TransactionService/Commands/AddTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Accounts.Domain.AccountAggregate; | ||
using Accounts.Domain.AccountAggregate.AccountEntity; | ||
using Accounts.Domain.AccountAggregate.TransactionEntity; | ||
using Accounts.Domain.TagEntity; | ||
using Enums; | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Primitives; | ||
using Primitives.Command; | ||
|
||
namespace Accounts.Application.TransactionService.Commands; | ||
|
||
public sealed class AddTransactionCommand( | ||
long id, | ||
CurrencyType currency, | ||
decimal amount, | ||
long[] tags, | ||
string description | ||
) : ICommandRequest<AddTransactionDto> | ||
{ | ||
public AccountId AccountId { get; } = new(id); | ||
|
||
public TransactionAmount TransactionAmount { get; } = new(currency, amount); | ||
|
||
public TagId[] Tags { get; } = Array.ConvertAll(tags, converter: t => new TagId(t)); | ||
|
||
public TransactionDescription Description { get; } = new(description); | ||
} | ||
|
||
public record AddTransactionDto( | ||
long Id | ||
); | ||
|
||
[UsedImplicitly] | ||
public sealed class AddTransactionCommandHandler( | ||
IAccountRepository accountRepo, | ||
ITagRepository tagRepo, | ||
[FromKeyedServices(key: "accounts")] IUnitOfWork unitOfWork | ||
) : ICommandRequestHandler<AddTransactionCommand, AddTransactionDto> | ||
{ | ||
public async Task<AddTransactionDto> Handle(AddTransactionCommand request, CancellationToken cancellationToken) | ||
{ | ||
var account = await accountRepo.GetAccountAsync(request.AccountId, cancellationToken); | ||
|
||
List<Tag> tags = []; | ||
|
||
foreach (var t in request.Tags) | ||
{ | ||
var tag = await tagRepo.GetTagAsync(t, cancellationToken); | ||
tags.Add(tag); | ||
} | ||
|
||
var id = account.AddTransaction(request.TransactionAmount, DateTime.UtcNow, request.Description, tags); | ||
|
||
await unitOfWork.CommitChangesAsync(cancellationToken); | ||
|
||
return new AddTransactionDto(id.Value); | ||
} | ||
} |
Oops, something went wrong.