Skip to content

Commit

Permalink
Refactoring (ivanpaulovich#245)
Browse files Browse the repository at this point in the history
* Refactoring

* Upgrade Nuget packages

* React updates
  • Loading branch information
ivanpaulovich authored Oct 12, 2020
1 parent f7db16b commit 5b6dc22
Show file tree
Hide file tree
Showing 100 changed files with 663 additions and 654 deletions.
2 changes: 1 addition & 1 deletion accounts-api/src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.12.0.21095">
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.13.1.21947">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion accounts-api/src/Application/Services/ICurrencyExchange.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Application.Services
{
using Domain.ValueObjects;
using System.Threading.Tasks;
using Domain.ValueObjects;

/// <summary>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion accounts-api/src/Application/Services/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public IDictionary<string, string[]> ModelState
{
get
{
var modelState = this._errorMessages
Dictionary<string, string[]> modelState = this._errorMessages
.ToDictionary(item => item.Key, item => item.Value.ToArray());

return modelState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Application.UseCases.CloseAccount
{
using System;
using System.Threading.Tasks;
using Domain;
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;

/// <inheritdoc />
public sealed class CloseAccountUseCase : ICloseAccountUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Application.UseCases.CloseAccount
{
using Application.Services;
using System;
using System.Threading.Tasks;
using Services;

/// <inheritdoc />
public sealed class CloseAccountValidationUseCase : ICloseAccountUseCase
Expand All @@ -17,10 +17,7 @@ public sealed class CloseAccountValidationUseCase : ICloseAccountUseCase
/// <summary>
/// Initializes a new instance of the <see cref="CloseAccountValidationUseCase" /> class.
/// </summary>
public CloseAccountValidationUseCase(ICloseAccountUseCase useCase)
{
this._useCase = useCase;
}
public CloseAccountValidationUseCase(ICloseAccountUseCase useCase) => this._useCase = useCase;

/// <inheritdoc />
public void SetOutputPort(IOutputPort outputPort)
Expand All @@ -32,7 +29,7 @@ public void SetOutputPort(IOutputPort outputPort)
/// <inheritdoc />
public Task Execute(Guid accountId)
{
var modelState = new Notification();
Notification modelState = new Notification();

if (accountId == Guid.Empty)
{
Expand Down
10 changes: 4 additions & 6 deletions accounts-api/src/Application/UseCases/Deposit/DepositUseCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Application.UseCases.Deposit
{
using System;
using System.Threading.Tasks;
using Domain;
using Domain.Credits;
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;

/// <inheritdoc />
public sealed class DepositUseCase : IDepositUseCase
Expand Down Expand Up @@ -43,12 +43,10 @@ public DepositUseCase(
public void SetOutputPort(IOutputPort outputPort) => this._outputPort = outputPort;

/// <inheritdoc />
public Task Execute(Guid accountId, decimal amount, string currency)
{
return this.Deposit(
public Task Execute(Guid accountId, decimal amount, string currency) =>
this.Deposit(
new AccountId(accountId),
new Money(amount, new Currency(currency)));
}

private async Task Deposit(AccountId accountId, Money amount)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,34 @@

namespace Application.UseCases.Deposit
{
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;
using Domain.ValueObjects;
using Services;

/// <inheritdoc />
public sealed class DepositValidationUseCase : IDepositUseCase
{
private readonly IDepositUseCase _useCase;
private IOutputPort? _outputPort;

private IOutputPort? _outputPort;

/// <summary>
/// Initializes a new instance of the <see cref="DepositValidationUseCase" /> class.
/// </summary>
/// </summary>
/// <param name="useCase"></param>
public DepositValidationUseCase(IDepositUseCase useCase)
{
this._useCase = useCase;
}
public DepositValidationUseCase(IDepositUseCase useCase) => this._useCase = useCase;

/// <inheritdoc />
public void SetOutputPort(IOutputPort outputPort)
public void SetOutputPort(IOutputPort outputPort)
{
this._outputPort = outputPort;
this._useCase.SetOutputPort(outputPort);
this._useCase.SetOutputPort(outputPort);
}

/// <inheritdoc />
public Task Execute(Guid accountId, decimal amount, string currency)
{
var modelState = new Notification();
Notification modelState = new Notification();

if (accountId == Guid.Empty)
{
Expand All @@ -49,11 +46,11 @@ public Task Execute(Guid accountId, decimal amount, string currency)
currency != Currency.Krona.Code)
{
modelState.Add(nameof(currency), "Currency is required.");
}

if (amount <= 0)
{
modelState.Add(nameof(amount), "Amount should be positive.");
}

if (amount <= 0)
{
modelState.Add(nameof(amount), "Amount should be positive.");
}

if (modelState.IsValid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Application.UseCases.GetAccount
{
using Domain;
using Domain.ValueObjects;
using System;
using System.Threading.Tasks;
using Domain;
using Domain.ValueObjects;

/// <inheritdoc />
public sealed class GetAccountUseCase : IGetAccountUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Application.UseCases.GetAccount
{
using Application.Services;
using System;
using System.Threading.Tasks;
using Services;

/// <inheritdoc />
public sealed class GetAccountValidationUseCase : IGetAccountUseCase
Expand All @@ -17,10 +17,7 @@ public sealed class GetAccountValidationUseCase : IGetAccountUseCase
/// <summary>
/// Initializes a new instance of the <see cref="GetAccountValidationUseCase" /> class.
/// </summary>
public GetAccountValidationUseCase(IGetAccountUseCase useCase)
{
this._useCase = useCase;
}
public GetAccountValidationUseCase(IGetAccountUseCase useCase) => this._useCase = useCase;

/// <inheritdoc />
public void SetOutputPort(IOutputPort outputPort)
Expand All @@ -32,7 +29,7 @@ public void SetOutputPort(IOutputPort outputPort)
/// <inheritdoc />
public Task Execute(Guid accountId)
{
var modelState = new Notification();
Notification modelState = new Notification();

if (accountId == Guid.Empty)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Application.UseCases.GetAccounts
{
using Domain;
using Services;
using System.Collections.Generic;
using System.Threading.Tasks;
using Domain;
using Services;

/// <inheritdoc />
public sealed class GetAccountsUseCase : IGetAccountsUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Application.UseCases.GetAccounts
{
using Domain;
using System.Collections.Generic;
using Domain;

/// <summary>
/// Output Port.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Application.UseCases.OpenAccount
{
using System;
using System.Threading.Tasks;
using Domain;
using Domain.Credits;
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;

/// <inheritdoc />
public sealed class OpenAccountUseCase : IOpenAccountUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Application.UseCases.OpenAccount
{
using System.Threading.Tasks;
using Domain.ValueObjects;
using Services;
using System.Threading.Tasks;

/// <inheritdoc />
public sealed class OpenAccountValidationUseCase : IOpenAccountUseCase
Expand All @@ -15,10 +15,8 @@ public sealed class OpenAccountValidationUseCase : IOpenAccountUseCase
private IOutputPort? _outputPort;

public OpenAccountValidationUseCase(
IOpenAccountUseCase useCase)
{
IOpenAccountUseCase useCase) =>
this._useCase = useCase;
}

/// <inheritdoc />
public void SetOutputPort(IOutputPort outputPort)
Expand All @@ -30,7 +28,7 @@ public void SetOutputPort(IOutputPort outputPort)
/// <inheritdoc />
public Task Execute(decimal amount, string currency)
{
var modelState = new Notification();
Notification modelState = new Notification();

if (currency != Currency.Dollar.Code &&
currency != Currency.Euro.Code &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace Application.UseCases.Transfer
{
using System;
using System.Threading.Tasks;
using Domain;
using Domain.Credits;
using Domain.Debits;
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;

/// <inheritdoc />
public sealed class TransferUseCase : ITransferUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Application.UseCases.Transfer
{
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;
using Domain.ValueObjects;
using Services;

/// <inheritdoc />
public sealed class TransferValidationUseCase : ITransferUseCase
Expand All @@ -18,10 +18,7 @@ public sealed class TransferValidationUseCase : ITransferUseCase
/// <summary>
/// Initializes a new instance of the <see cref="TransferUseCase" /> class.
/// </summary>
public TransferValidationUseCase(ITransferUseCase transferUseCase)
{
this._useCase = transferUseCase;
}
public TransferValidationUseCase(ITransferUseCase transferUseCase) => this._useCase = transferUseCase;

/// <inheritdoc />
public void SetOutputPort(IOutputPort outputPort)
Expand All @@ -33,7 +30,7 @@ public void SetOutputPort(IOutputPort outputPort)
/// <inheritdoc />
public Task Execute(Guid originAccountId, Guid destinationAccountId, decimal amount, string currency)
{
var modelState = new Notification();
Notification modelState = new Notification();

if (originAccountId == Guid.Empty)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Application.UseCases.Withdraw
{
using System;
using System.Threading.Tasks;
using Domain;
using Domain.Debits;
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;

/// <inheritdoc />
public sealed class WithdrawUseCase : IWithdrawUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Application.UseCases.Withdraw
{
using Domain.ValueObjects;
using Services;
using System;
using System.Threading.Tasks;
using Domain.ValueObjects;
using Services;

/// <inheritdoc />
public sealed class WithdrawValidationUseCase : IWithdrawUseCase
Expand All @@ -18,10 +18,7 @@ public sealed class WithdrawValidationUseCase : IWithdrawUseCase
/// <summary>
/// Initializes a new instance of the <see cref="WithdrawValidationUseCase" /> class.
/// </summary>
public WithdrawValidationUseCase(IWithdrawUseCase withdrawUseCase)
{
this._useCase = withdrawUseCase;
}
public WithdrawValidationUseCase(IWithdrawUseCase withdrawUseCase) => this._useCase = withdrawUseCase;

/// <inheritdoc />
public void SetOutputPort(IOutputPort outputPort)
Expand All @@ -33,7 +30,7 @@ public void SetOutputPort(IOutputPort outputPort)
/// <inheritdoc />
public Task Execute(Guid accountId, decimal amount, string currency)
{
var modelState = new Notification();
Notification modelState = new Notification();

if (accountId == Guid.Empty)
{
Expand Down
2 changes: 1 addition & 1 deletion accounts-api/src/Domain/AccountNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Domain
{
using System;
using Credits;
using Debits;
using System;
using ValueObjects;

/// <inheritdoc />
Expand Down
Loading

0 comments on commit 5b6dc22

Please sign in to comment.