Skip to content

Commit

Permalink
.:
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigojap committed Feb 2, 2021
1 parent 42fc6f2 commit 22cf314
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
16 changes: 4 additions & 12 deletions VirtualMind.Application/Queries/GetCurrencyExchange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@
namespace VirtualMind.Application.Queries
{
public class GetCurrencyExchange : IRequest<List<ExchangeRateDTO>>
{
//public AcceptableCurrencies CurrencyType { get; set; }

{
public string CurrencyType { get; set; }
}

//TODO: Put this on domain
public enum AcceptableCurrencies
{
USD,
REAL
}
}

public class GetCurrencyExchangeHandler : IRequestHandler<GetCurrencyExchange, List<ExchangeRateDTO>>
{
public async Task<List<ExchangeRateDTO>> Handle(GetCurrencyExchange request, CancellationToken cancellationToken)
{
{
//MUST BE A SERVICE API
var exchange = new ExchangeRateDTO();
exchange.LastUpdate = "today";
exchange.Purchase = "12.00";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentValidation;
using VirtualMind.Domain.Enums;

namespace VirtualMind.Application.Queries
{
Expand All @@ -8,7 +9,10 @@ public GetCurrencyExchangeValidator()
{
RuleFor(input => input.CurrencyType)
.NotNull().WithMessage("[CurrencyType] can't be null!")
.NotEmpty().WithMessage("[CurrencyType] field is required!");
.NotEmpty().WithMessage("[CurrencyType] field is required!");

RuleFor(input => input.CurrencyType)
.IsEnumName(typeof(Currency), false).WithMessage("Invalid [CurrencyType]!");
}
}
}
4 changes: 4 additions & 0 deletions VirtualMind.Application/VirtualMind.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<Folder Include="Commands\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VirtualMind.Domain\VirtualMind.Domain.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions VirtualMind.Domain/Entities/ExchangeRate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace VirtualMind.Domain.Entities
{
public class ExchangeRate
{
public string Purchase { get; set; }

public string Sale { get; set; }

public string LastUpdate { get; set; }
}
}
6 changes: 3 additions & 3 deletions VirtualMind.Domain/Enums/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public enum Currency
{
USD = 0,
REAL= 1
}
USD,
BRL
}
}
4 changes: 0 additions & 4 deletions VirtualMind.Domain/VirtualMind.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="Entities\" />
</ItemGroup>

</Project>

0 comments on commit 22cf314

Please sign in to comment.