Skip to content

Commit ad1f812

Browse files
authored
Release v0.6.0
* Adds build step in matrix_test_result.yml * Adds Core.Infra project * Adds Providers to Category, Account, Balance and Transaction * Adds Infra project reference in WebApi project * Adds IncreaseAmountAsync and DecreaseAmountAsync * Adds resource for error messages to core project * Adds ValidationErrorMessageProvider * Adds ErrorMessageProvider * Adds ConceptWords to Resources * Adds CommitAsync to every Repository * Adds CommitAsync to ever Provider call to Repository * Improves TransactionProvider.delete tests * Improves integration test cases * Updates coverage_report.yml java version * Changes app.settings database to financial_hub_test * Changes TransactionBalancesService to Obsolete * Moves Transaction delete logic to TransactionsProvider * Moves Transaction create logic to TransactionsProvider * Moves Default Balance Creation to AccountProvider * Moves Merged Services to Provider * Moves interface Usings to global Infra Project * Disables Update Transaction endpoint * Removes IAccountBalanceService and AccountBalanceService * Removes CreateAsync and DeleteAsync from TransactionBalancesService * Removes Mapper From Application layer * Removes TransactionBalanceService.DeleteTransaction * Removes Entity references from Service Projects * Fixes DeleteTransaction integration tests fixes * Fix DeleteTransaction being bocked instead of UpdateTransaction
1 parent 431698e commit ad1f812

128 files changed

Lines changed: 3399 additions & 1661 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/coverage_report.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ jobs:
4444

4545
- name: Dotnet restore tools
4646
run: dotnet tool restore
47+
48+
- name: Set up JDK 17
49+
uses: actions/setup-java@v3
50+
with:
51+
java-version: 17
52+
distribution: 'zulu' # Alternative distribution options are available.
4753

4854
- name: Cache SonarCloud packages
4955
uses: actions/cache@v1
@@ -87,4 +93,4 @@ jobs:
8793
run:
8894
dotnet tool run dotnet-sonarscanner end
8995
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
90-
96+

.github/workflows/matrix_test_result.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ jobs:
4444
project-dir: ${{ inputs.dir }}
4545
dotnet-version: 6.0.x
4646

47+
- name: Build Project
48+
run: dotnet build ${{ inputs.dir }}
49+
--configuration Release
50+
--no-restore
51+
4752
- name: Run Unit Tests
4853
uses: ./.github/actions/run-tests
4954
with:
@@ -62,4 +67,4 @@ jobs:
6267
github_token: ${{ secrets.GITHUB_TOKEN }}
6368
check_name: ${{ matrix.project }} project test results
6469
action_fail: true
65-
files: "./tests/${{ matrix.project }}/**/TestResults/Results-*.xml"
70+
files: "./tests/${{ matrix.project }}/**/TestResults/Results-*.xml"

src/api/.editorconfig

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ csharp_style_var_for_built_in_types = false
8181
csharp_style_var_when_type_is_apparent = false
8282

8383
# Membros aptos para expressão
84-
csharp_style_expression_bodied_accessors = true
85-
csharp_style_expression_bodied_constructors = false
86-
csharp_style_expression_bodied_indexers = true
87-
csharp_style_expression_bodied_lambdas = true
88-
csharp_style_expression_bodied_local_functions = false
89-
csharp_style_expression_bodied_methods = false
90-
csharp_style_expression_bodied_operators = false
91-
csharp_style_expression_bodied_properties = true
84+
csharp_style_expression_bodied_accessors = true:silent
85+
csharp_style_expression_bodied_constructors = false:silent
86+
csharp_style_expression_bodied_indexers = true:silent
87+
csharp_style_expression_bodied_lambdas = true:silent
88+
csharp_style_expression_bodied_local_functions = false:silent
89+
csharp_style_expression_bodied_methods = false:silent
90+
csharp_style_expression_bodied_operators = false:silent
91+
csharp_style_expression_bodied_properties = true:silent
9292

9393
# Preferências de correspondência de padrões
94-
csharp_style_pattern_matching_over_as_with_null_check = true
95-
csharp_style_pattern_matching_over_is_with_cast_check = true
96-
csharp_style_prefer_extended_property_pattern = true
97-
csharp_style_prefer_not_pattern = true
98-
csharp_style_prefer_pattern_matching = true
99-
csharp_style_prefer_switch_expression = true
94+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
95+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
96+
csharp_style_prefer_extended_property_pattern = true:suggestion
97+
csharp_style_prefer_not_pattern = true:suggestion
98+
csharp_style_prefer_pattern_matching = true:silent
99+
csharp_style_prefer_switch_expression = true:suggestion
100100

101101
# Preferências de verificação nula
102102
csharp_style_conditional_delegate_call = true
@@ -131,7 +131,7 @@ csharp_style_unused_value_assignment_preference = discard_variable
131131
csharp_style_unused_value_expression_statement_preference = discard_variable
132132

133133
# Preferências da diretiva 'using'
134-
csharp_using_directive_placement = outside_namespace
134+
csharp_using_directive_placement = outside_namespace:silent
135135

136136
# Preferências de nova linha
137137
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
@@ -236,3 +236,11 @@ dotnet_diagnostic.CS8618.severity = none
236236

237237
# CS8632: A anotação para tipos de referência anuláveis deve ser usada apenas em código em um contexto de anotações '#nullable'.
238238
dotnet_diagnostic.CS8632.severity = none
239+
240+
[*.{cs,vb}]
241+
end_of_line = crlf
242+
dotnet_style_qualification_for_field = false:silent
243+
dotnet_style_qualification_for_property = false:silent
244+
dotnet_style_qualification_for_method = false:silent
245+
dotnet_style_qualification_for_event = false:silent
246+
dotnet_style_readonly_field = true:suggestion

src/api/FinancialHub.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
8282
.editorconfig = .editorconfig
8383
EndProjectSection
8484
EndProject
85+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra", "core\FinancialHub.Core.Infra\FinancialHub.Core.Infra.csproj", "{945AF69F-6D9F-4ECF-9AA1-6D96A4C94372}"
86+
EndProject
87+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Tests", "..\..\tests\core\FinancialHub.Core.Infra.Tests\FinancialHub.Core.Infra.Tests.csproj", "{5D9FE20B-524A-48D8-ACE1-7C114D9E01A4}"
88+
EndProject
8589
Global
8690
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8791
Debug|Any CPU = Debug|Any CPU
@@ -184,6 +188,14 @@ Global
184188
{A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Debug|Any CPU.Build.0 = Debug|Any CPU
185189
{A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Release|Any CPU.ActiveCfg = Release|Any CPU
186190
{A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Release|Any CPU.Build.0 = Release|Any CPU
191+
{945AF69F-6D9F-4ECF-9AA1-6D96A4C94372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
192+
{945AF69F-6D9F-4ECF-9AA1-6D96A4C94372}.Debug|Any CPU.Build.0 = Debug|Any CPU
193+
{945AF69F-6D9F-4ECF-9AA1-6D96A4C94372}.Release|Any CPU.ActiveCfg = Release|Any CPU
194+
{945AF69F-6D9F-4ECF-9AA1-6D96A4C94372}.Release|Any CPU.Build.0 = Release|Any CPU
195+
{5D9FE20B-524A-48D8-ACE1-7C114D9E01A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
196+
{5D9FE20B-524A-48D8-ACE1-7C114D9E01A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
197+
{5D9FE20B-524A-48D8-ACE1-7C114D9E01A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
198+
{5D9FE20B-524A-48D8-ACE1-7C114D9E01A4}.Release|Any CPU.Build.0 = Release|Any CPU
187199
EndGlobalSection
188200
GlobalSection(SolutionProperties) = preSolution
189201
HideSolutionNode = FALSE
@@ -223,6 +235,8 @@ Global
223235
{551319E1-1415-449B-A9B7-B49AA182D6C4} = {022A9AE7-CA3B-4DD1-934B-FBBF680312B1}
224236
{F24D2732-A777-4246-A5E2-633FB552B999} = {2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C}
225237
{A1CE8588-9FE3-4ADB-AEB9-E34680091A78} = {A93CC4E0-F468-49C7-8429-9384A124BB2D}
238+
{945AF69F-6D9F-4ECF-9AA1-6D96A4C94372} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777}
239+
{5D9FE20B-524A-48D8-ACE1-7C114D9E01A4} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777}
226240
EndGlobalSection
227241
GlobalSection(ExtensibilityGlobals) = postSolution
228242
SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8}

src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ namespace FinancialHub.Common.Interfaces.Repositories
66
/// Base repository with basic CRUD methods
77
/// </summary>
88
/// <typeparam name="T">Any Entity that inherits <see cref="BaseEntity"/> </typeparam>
9-
public interface IBaseRepository<T>
10-
where T : BaseEntity
9+
public interface IBaseRepository<T> where T : BaseEntity
1110
{
1211
/// <summary>
1312
/// Adds an entity to the database
@@ -37,5 +36,10 @@ public interface IBaseRepository<T>
3736
/// </summary>
3837
/// <param name="id">Id of the choosen entity</param>
3938
Task<T?> GetByIdAsync(Guid id);
39+
/// <summary>
40+
/// Commit All changes to the database
41+
/// </summary>
42+
/// <returns>Number of affected entities</returns>
43+
Task<int> CommitAsync();
4044
}
4145
}

src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.Extensions.DependencyInjection;
2-
using FinancialHub.Core.Application.Mappers;
32
using FinancialHub.Core.Application.Services;
43
using FinancialHub.Core.Application.Validators;
54
using FluentValidation;
@@ -10,7 +9,6 @@ public static class IServiceCollectionExtensions
109
{
1110
public static IServiceCollection AddCoreServices(this IServiceCollection services)
1211
{
13-
services.AddMapper();
1412
services.AddServices();
1513
services.AddValidators();
1614

@@ -24,17 +22,6 @@ private static IServiceCollection AddServices(this IServiceCollection services)
2422
services.AddScoped<ITransactionsService, TransactionsService>();
2523
services.AddScoped<IBalancesService, BalancesService>();
2624

27-
services.AddScoped<IAccountBalanceService, AccountBalanceService>();
28-
services.AddScoped<ITransactionBalanceService, TransactionBalanceService>();
29-
30-
return services;
31-
}
32-
33-
private static IServiceCollection AddMapper(this IServiceCollection services)
34-
{
35-
services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile));
36-
services.AddScoped<IMapperWrapper, FinancialHubMapperWrapper>();
37-
3825
return services;
3926
}
4027

src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,4 @@
1616
<ProjectReference Include="..\FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj" />
1717
</ItemGroup>
1818

19-
<ItemGroup>
20-
<Compile Update="Resources\ErrorMessages.Designer.cs">
21-
<DependentUpon>ErrorMessages.resx</DependentUpon>
22-
<DesignTime>True</DesignTime>
23-
<AutoGen>True</AutoGen>
24-
</Compile>
25-
</ItemGroup>
26-
27-
<ItemGroup>
28-
<EmbeddedResource Update="Resources\ErrorMessages.resx">
29-
<LastGenOutput>ErrorMessages.Designer.cs</LastGenOutput>
30-
<Generator>ResXFileCodeGenerator</Generator>
31-
</EmbeddedResource>
32-
</ItemGroup>
33-
3419
</Project>

src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,63 @@
1-
namespace FinancialHub.Core.Application.Services
1+
using FinancialHub.Core.Domain.Interfaces.Resources;
2+
3+
namespace FinancialHub.Core.Application.Services
24
{
35
public class AccountsService : IAccountsService
46
{
5-
private readonly IMapperWrapper mapper;
6-
private readonly IAccountsRepository repository;
7+
private readonly IAccountsProvider provider;
8+
private readonly IErrorMessageProvider errorMessageProvider;
79

8-
public AccountsService(IMapperWrapper mapper,IAccountsRepository repository)
10+
public AccountsService(IAccountsProvider provider, IErrorMessageProvider errorMessageProvider)
911
{
10-
this.mapper = mapper;
11-
this.repository = repository;
12+
this.provider = provider;
13+
this.errorMessageProvider = errorMessageProvider;
1214
}
1315

1416
public async Task<ServiceResult<AccountModel>> CreateAsync(AccountModel account)
1517
{
16-
var entity = mapper.Map<AccountEntity>(account);
17-
18-
entity = await this.repository.CreateAsync(entity);
19-
20-
return mapper.Map<AccountModel>(entity);
18+
return await this.provider.CreateAsync(account);
2119
}
2220

2321
public async Task<ServiceResult<int>> DeleteAsync(Guid id)
2422
{
25-
var count = await this.repository.DeleteAsync(id);
26-
27-
return new ServiceResult<int>(count);
23+
return await this.provider.DeleteAsync(id);
2824
}
2925

3026
public async Task<ServiceResult<ICollection<AccountModel>>> GetAllByUserAsync(string userId)
3127
{
32-
var entities = await this.repository.GetAllAsync();
33-
34-
var list = this.mapper.Map<ICollection<AccountModel>>(entities);
28+
var accounts = await this.provider.GetAllAsync();
3529

36-
return list.ToArray();
30+
return accounts.ToArray();
3731
}
3832

3933
public async Task<ServiceResult<AccountModel>> GetByIdAsync(Guid id)
4034
{
41-
var entity = await this.repository.GetByIdAsync(id);
35+
var existingAccount = await this.provider.GetByIdAsync(id);
36+
if (existingAccount == null)
37+
{
38+
return new NotFoundError(
39+
this.errorMessageProvider.NotFoundMessage("Account", id)
40+
);
41+
}
4242

43-
return this.mapper.Map<AccountModel>(entity);
43+
return existingAccount;
4444
}
4545

4646
public async Task<ServiceResult<AccountModel>> UpdateAsync(Guid id, AccountModel account)
4747
{
48-
var entity = await this.repository.GetByIdAsync(id);
48+
var existingAccountResult = await this.GetByIdAsync(id);
49+
if (existingAccountResult.HasError)
50+
return existingAccountResult.Error;
4951

50-
if (entity == null)
52+
var updatedAccount = await this.provider.UpdateAsync(id, account);
53+
if (updatedAccount == null)
5154
{
52-
return new NotFoundError($"Not found account with id {id}");
55+
return new InvalidDataError(
56+
this.errorMessageProvider.UpdateFailedMessage("Account", id)
57+
);
5358
}
5459

55-
entity = this.mapper.Map<AccountEntity>(account);
56-
57-
entity = await this.repository.UpdateAsync(entity);
58-
59-
return mapper.Map<AccountModel>(entity);
60+
return updatedAccount;
6061
}
6162
}
6263
}

0 commit comments

Comments
 (0)