feat: refinamentos
This commit is contained in:
@@ -42,6 +42,7 @@ bld/
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
.vscode/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
|
||||
<PackageVersion Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
<PackageVersion Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageVersion Include="Bogus" Version="35.3.0" />
|
||||
<PackageVersion Include="Bogus" Version="35.3.2" />
|
||||
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
|
||||
<PackageVersion Include="EntityFrameworkCore.DataEncryption" Version="5.0.0" />
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.100",
|
||||
"version": "8.0.101",
|
||||
"rollForward": "latestMajor",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ using Shop.Core.Extensions;
|
||||
|
||||
namespace Shop.Application.Behaviors;
|
||||
|
||||
public class LoggingBehavior<TRequest, TResponse>(ILogger<LoggingBehavior<TRequest, TResponse>> logger) : IPipelineBehavior<TRequest, TResponse>
|
||||
where TRequest : IRequest<TResponse>
|
||||
public class LoggingBehavior<TRequest, TResponse>(ILogger<LoggingBehavior<TRequest, TResponse>> logger)
|
||||
: IPipelineBehavior<TRequest, TResponse> where TRequest : IRequest<TResponse>
|
||||
{
|
||||
private readonly ILogger<LoggingBehavior<TRequest, TResponse>> _logger = logger;
|
||||
|
||||
|
||||
@@ -4,16 +4,11 @@ using Shop.Infrastructure.Data.Extensions;
|
||||
|
||||
namespace Shop.Infrastructure.Data.Context;
|
||||
|
||||
public abstract class BaseDbContext<TContext> : DbContext
|
||||
public abstract class BaseDbContext<TContext>(DbContextOptions<TContext> dbOptions) : DbContext(dbOptions)
|
||||
where TContext : DbContext
|
||||
{
|
||||
private const string Collation = "Latin1_General_CI_AI";
|
||||
|
||||
protected BaseDbContext(DbContextOptions<TContext> dbOptions)
|
||||
: base(dbOptions)
|
||||
{
|
||||
}
|
||||
|
||||
public override ChangeTracker ChangeTracker
|
||||
{
|
||||
get
|
||||
|
||||
@@ -11,18 +11,12 @@ namespace Shop.Infrastructure.Data.Repositories.Common;
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">The type of the entity.</typeparam>
|
||||
/// <typeparam name="Tkey">The type of the entity's key.</typeparam>
|
||||
internal abstract class BaseWriteOnlyRepository<TEntity, Tkey> : IWriteOnlyRepository<TEntity, Tkey>
|
||||
internal abstract class BaseWriteOnlyRepository<TEntity, Tkey>(WriteDbContext context) : IWriteOnlyRepository<TEntity, Tkey>
|
||||
where TEntity : class, IEntity<Tkey>
|
||||
where Tkey : IEquatable<Tkey>
|
||||
{
|
||||
private readonly DbSet<TEntity> _dbSet;
|
||||
protected readonly WriteDbContext Context;
|
||||
|
||||
protected BaseWriteOnlyRepository(WriteDbContext context)
|
||||
{
|
||||
Context = context;
|
||||
_dbSet = context.Set<TEntity>();
|
||||
}
|
||||
private readonly DbSet<TEntity> _dbSet = context.Set<TEntity>();
|
||||
protected readonly WriteDbContext Context = context;
|
||||
|
||||
public void Add(TEntity entity) =>
|
||||
_dbSet.Add(entity);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ApiResponse
|
||||
new() { Success = false, StatusCode = StatusCodes.Status500InternalServerError, Errors = errors };
|
||||
|
||||
private static ApiErrorResponse[] CreateErrors(string errorMessage) =>
|
||||
new[] { new ApiErrorResponse(errorMessage) };
|
||||
[new ApiErrorResponse(errorMessage)];
|
||||
|
||||
public override string ToString() =>
|
||||
$"Success: {Success} | StatusCode: {StatusCode} | HasErrors: {Errors.Any()}";
|
||||
|
||||
@@ -10,18 +10,15 @@ namespace Shop.Query.Data.Repositories;
|
||||
/// </summary>
|
||||
/// <typeparam name="TQueryModel">The type of the query model.</typeparam>
|
||||
/// <typeparam name="Tkey">The type of the key.</typeparam>
|
||||
internal abstract class BaseReadOnlyRepository<TQueryModel, Tkey> : IReadOnlyRepository<TQueryModel, Tkey>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="BaseReadOnlyRepository{TQueryModel, Tkey}"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="context">The read database context.</param>
|
||||
internal abstract class BaseReadOnlyRepository<TQueryModel, Tkey>(IReadDbContext context) : IReadOnlyRepository<TQueryModel, Tkey>
|
||||
where TQueryModel : IQueryModel<Tkey>
|
||||
where Tkey : IEquatable<Tkey>
|
||||
{
|
||||
protected readonly IMongoCollection<TQueryModel> Collection;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseReadOnlyRepository{TQueryModel, Tkey}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The read database context.</param>
|
||||
protected BaseReadOnlyRepository(IReadDbContext context) =>
|
||||
Collection = context.GetCollection<TQueryModel>();
|
||||
protected readonly IMongoCollection<TQueryModel> Collection = context.GetCollection<TQueryModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a query model by its id.
|
||||
|
||||
Reference in New Issue
Block a user