Skip to content

Commit

Permalink
chore: updating packages
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarmesquita committed May 18, 2024
1 parent 50d85cb commit 1716374
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/Api.Crud.Client/Api.Crud.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<RootNamespace>eQuantic.Core.Api.Crud.Client</RootNamespace>
<AssemblyName>eQuantic.Core.Api.Crud.Client</AssemblyName>
<AssemblyTitle>eQuantic.Core.Api.Crud.Client</AssemblyTitle>
<AssemblyVersion>1.6.25.0</AssemblyVersion>
<FileVersion>1.6.25.0</FileVersion>
<Version>1.6.25.0</Version>
<AssemblyVersion>1.6.26.0</AssemblyVersion>
<FileVersion>1.6.26.0</FileVersion>
<Version>1.6.26.0</Version>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>

<PackageId>eQuantic.Core.Api.Crud.Client</PackageId>
Expand Down Expand Up @@ -46,7 +46,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="eQuantic.Core" Version="1.7.0" />
<PackageReference Include="eQuantic.Core.Api.Client" Version="1.6.18" />
<PackageReference Include="eQuantic.Core.Api.Client" Version="1.6.19" />
<PackageReference Include="eQuantic.Linq" Version="1.3.1" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions src/Api.Crud/Api.Crud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<AssemblyName>eQuantic.Core.Api.Crud</AssemblyName>
<RootNamespace>eQuantic.Core.Api.Crud</RootNamespace>
<AssemblyTitle>eQuantic.Core.Api.Crud</AssemblyTitle>
<AssemblyVersion>1.6.25.0</AssemblyVersion>
<FileVersion>1.6.25.0</FileVersion>
<Version>1.6.25.0</Version>
<AssemblyVersion>1.6.26.0</AssemblyVersion>
<FileVersion>1.6.26.0</FileVersion>
<Version>1.6.26.0</Version>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>

<PackageId>eQuantic.Core.Api.Crud</PackageId>
Expand Down Expand Up @@ -37,7 +37,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="eQuantic.Core.Api" Version="1.6.18" />
<PackageReference Include="eQuantic.Core.Api" Version="1.6.19" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
</ItemGroup>

Expand Down
14 changes: 4 additions & 10 deletions src/Api.Crud/Filters/ValidationFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

namespace eQuantic.Core.Api.Crud.Filters;

public class ValidationFilter<T> : IEndpointFilter where T : class
public class ValidationFilter<T>(IValidator<T> validator) : IEndpointFilter
where T : class
{
private readonly IValidator<T> _validator;

public ValidationFilter(IValidator<T> validator)
{
_validator = validator;
}

public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
{
var obj = context.Arguments.FirstOrDefault(x => x?.GetType() == typeof(T)) as T;
Expand All @@ -22,11 +16,11 @@ public ValidationFilter(IValidator<T> validator)
return Results.BadRequest();
}

var validationResult = await _validator.ValidateAsync(obj);
var validationResult = await validator.ValidateAsync(obj);

if (!validationResult.IsValid)
{
return Results.BadRequest(new ValidationErrorResult($"Invalid request of {typeof(T).Name}", null, validationResult.ToDictionary()));
return Results.BadRequest(new ErrorResult($"Invalid request of {typeof(T).Name}", validationResult.ToDictionary()));
}

return await next(context);
Expand Down
12 changes: 6 additions & 6 deletions src/Application.Crud/Application.Crud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<RootNamespace>eQuantic.Core.Application.Crud</RootNamespace>
<AssemblyName>eQuantic.Core.Application.Crud</AssemblyName>
<AssemblyTitle>eQuantic.Core.Application.Crud</AssemblyTitle>
<AssemblyVersion>1.6.25.0</AssemblyVersion>
<FileVersion>1.6.25.0</FileVersion>
<Version>1.6.25.0</Version>
<AssemblyVersion>1.6.26.0</AssemblyVersion>
<FileVersion>1.6.26.0</FileVersion>
<Version>1.6.26.0</Version>
<TargetFrameworks>netstandard2.1;net7.0;net8.0</TargetFrameworks>

<PackageId>eQuantic.Core.Application.Crud</PackageId>
Expand Down Expand Up @@ -37,9 +37,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="eQuantic.Core.Application" Version="1.6.18" />
<PackageReference Include="eQuantic.Core.Domain" Version="1.6.18" />
<PackageReference Include="eQuantic.Core.Exceptions" Version="1.6.18" />
<PackageReference Include="eQuantic.Core.Application" Version="1.6.19" />
<PackageReference Include="eQuantic.Core.Domain" Version="1.6.19" />
<PackageReference Include="eQuantic.Core.Exceptions" Version="1.6.19" />
<PackageReference Include="eQuantic.Mapper" Version="1.2.4" />
<PackageReference Include="Humanizer" Version="2.14.1" />
</ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions src/Application.Crud/Services/CrudServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class CrudServiceBase<TEntity, TRequest, TDataEntity, TUser, TKe
{
public virtual async Task<TKey> CreateAsync(CreateRequest<TRequest> request, CancellationToken cancellationToken = default)
{
var item = await OnMapRequestAsync(CrudAction.Create, request.Body);
var item = await OnMapRequestAsync(CrudAction.Create, request.Body, cancellationToken: cancellationToken);
if (item == null)
{
Logger.LogError("{ServiceName} - Create: Bad request of {Name}", GetType().Name, typeof(TRequest).Name);
Expand Down Expand Up @@ -78,7 +78,7 @@ public virtual async Task<bool> UpdateAsync(UpdateRequest<TRequest, TKey> reques

await OnBeforeUpdateAsync(request, item, cancellationToken);

await OnMapRequestAsync(CrudAction.Update, request.Body, item);
await OnMapRequestAsync(CrudAction.Update, request.Body, item, cancellationToken: cancellationToken);

if (item is IEntityTimeTrack itemWithTimeTrack)
{
Expand Down Expand Up @@ -151,6 +151,13 @@ public virtual async Task<bool> DeleteAsync(ItemRequest<TKey> request, Cancellat
return Map(request, dataEntity, mappingPriority, cancellationToken);
}

/// <summary>
/// This method is invoked after the request entity has been mapped
/// </summary>
/// <param name="request"></param>
/// <param name="dataEntity"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
protected virtual Task OnBeforeCreateAsync(CreateRequest<TRequest> request, TDataEntity? dataEntity, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
Expand Down

0 comments on commit 1716374

Please sign in to comment.