feat: refinamentos
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- "README.md"
|
||||
schedule:
|
||||
- cron: "37 5 * * 3"
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ["csharp"]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
@@ -0,0 +1,31 @@
|
||||
name: DevSkim
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- "README.md"
|
||||
schedule:
|
||||
- cron: "34 13 * * 5"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: DevSkim
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run DevSkim scanner
|
||||
uses: microsoft/DevSkim-Action@v1
|
||||
|
||||
- name: Upload DevSkim scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: devskim-results.sarif
|
||||
@@ -1,5 +1,3 @@
|
||||
# Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service.
|
||||
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
# Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service.
|
||||
|
||||
# docker-compose up -d
|
||||
# docker-compose up --build
|
||||
# docker-compose down
|
||||
# docker-compose down -v
|
||||
|
||||
version: '3.9'
|
||||
|
||||
networks:
|
||||
|
||||
@@ -4,7 +4,16 @@ using Shop.Core.Abstractions;
|
||||
|
||||
namespace Shop.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Repositório (somente leitura).
|
||||
/// </summary>
|
||||
/// <typeparam name="TQueryModel">O tipo do modelo.</typeparam>
|
||||
public interface IReadOnlyRepository<TQueryModel> where TQueryModel : BaseQueryModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Obtém o modelo por Id.
|
||||
/// </summary>
|
||||
/// <param name="id">O Id.</param>
|
||||
/// <returns>O modelo se existir, caso contrário; nulo.</returns>
|
||||
Task<TQueryModel> GetByIdAsync(Guid id);
|
||||
}
|
||||
@@ -3,6 +3,10 @@ using Shop.Core.Abstractions;
|
||||
|
||||
namespace Shop.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Repositório (somente escrita).
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">O tipo da entidade.</typeparam>
|
||||
public interface IWriteOnlyRepository<TEntity> where TEntity : BaseEntity
|
||||
{
|
||||
void Add(TEntity entity);
|
||||
|
||||
@@ -9,16 +9,16 @@ public class QueryModelToEntityProfile : Profile
|
||||
{
|
||||
public QueryModelToEntityProfile()
|
||||
{
|
||||
// Desabilitando o mapeando via construtor.
|
||||
// A classe só deverá ser inicializada no construtor manualmente (via dev).
|
||||
DisableConstructorMapping();
|
||||
|
||||
// Mapeando propriedades com "setters" privados.
|
||||
ShouldMapProperty = _ => true;
|
||||
|
||||
// Desabilitando o mapeando via construtor.
|
||||
// A classe só deverá ser inicializada no construtor manualmente (via dev)
|
||||
DisableConstructorMapping();
|
||||
|
||||
CreateMap<CustomerQueryModel, Customer>(MemberList.Destination)
|
||||
.ForMember(dest => dest.Email, cfg => cfg.MapFrom(src => new Email(src.Email)))
|
||||
.ForMember(dest => dest.DomainEvents, cfg => cfg.Ignore())
|
||||
.AfterMap((_, e) => e.ClearDomainEvents());
|
||||
.AfterMap((_, customer) => customer.ClearDomainEvents());
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,12 @@ public class CustomerWriteOnlyRepository : BaseWriteOnlyRepository<Customer>, IC
|
||||
}
|
||||
|
||||
public async Task<bool> ExistsByEmailAsync(Email email)
|
||||
=> await DbSet.AsNoTracking().AnyAsync(c => c.Email.Address == email.Address);
|
||||
=> await DbSet
|
||||
.AsNoTracking()
|
||||
.AnyAsync(customer => customer.Email.Address == email.Address);
|
||||
|
||||
public async Task<bool> ExistsByEmailAsync(Email email, Guid currentId)
|
||||
=> await DbSet.AsNoTracking().AnyAsync(c => c.Email.Address == email.Address && c.Id != currentId);
|
||||
=> await DbSet
|
||||
.AsNoTracking()
|
||||
.AnyAsync(customer => customer.Email.Address == email.Address && customer.Id != currentId);
|
||||
}
|
||||
Reference in New Issue
Block a user