From e129f36738a5d56ff3d445b0d1a406a153d23e8a Mon Sep 17 00:00:00 2001 From: Jean Gatto Date: Thu, 25 Jul 2024 14:53:06 -0300 Subject: [PATCH] refactor: removido pacotes depreciados --- Directory.Packages.props | 7 ++----- requests.http | 4 ++-- .../Data/Context/WriteDbContext.cs | 12 ------------ .../Data/Mappings/CustomerConfiguration.cs | 4 +--- src/Shop.Infrastructure/Shop.Infrastructure.csproj | 3 --- .../Controllers/v1/CustomersController.cs | 1 + src/Shop.PublicApi/Program.cs | 8 ++++---- src/Shop.PublicApi/Shop.PublicApi.csproj | 4 ++-- 8 files changed, 12 insertions(+), 31 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 891b20f..093706e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,6 +7,8 @@ + + @@ -15,15 +17,11 @@ - - - - @@ -32,7 +30,6 @@ - diff --git a/requests.http b/requests.http index c9f62a7..f902c4b 100644 --- a/requests.http +++ b/requests.http @@ -1,6 +1,6 @@ ### Register a new customer -POST http://localhost:53625/api/customers HTTP/1.1 +POST http://localhost:56344/api/customers HTTP/1.1 content-type: application/json { @@ -13,5 +13,5 @@ content-type: application/json ### Gets a list of all customers -GET http://localhost:53625/api/customers HTTP/1.1 +GET http://localhost:56344/api/customers HTTP/1.1 content-type: application/json \ No newline at end of file diff --git a/src/Shop.Infrastructure/Data/Context/WriteDbContext.cs b/src/Shop.Infrastructure/Data/Context/WriteDbContext.cs index 5e35913..f353ad9 100644 --- a/src/Shop.Infrastructure/Data/Context/WriteDbContext.cs +++ b/src/Shop.Infrastructure/Data/Context/WriteDbContext.cs @@ -1,6 +1,4 @@ using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.DataEncryption; -using Microsoft.EntityFrameworkCore.DataEncryption.Providers; using Shop.Domain.Entities.CustomerAggregate; using Shop.Infrastructure.Data.Mappings; @@ -9,15 +7,6 @@ namespace Shop.Infrastructure.Data.Context; public class WriteDbContext(DbContextOptions dbOptions) : BaseDbContext(dbOptions) { - #region Encryption - - private static readonly byte[] EncryptionKey = [189, 3, 80, 118, 242, 164, 9, 197, 106, 166, 122, 118, 161, 212, 106, 26, 171, 18, 178, 98, 86, 102, 196, 6, 78, 249, 4, 164, 66, 154, 218, 126]; - private static readonly byte[] EncryptionVector = [163, 225, 4, 33, 227, 178, 113, 128, 174, 23, 9, 144, 213, 158, 134, 48]; - - private readonly IEncryptionProvider _encryptionProvider = new AesProvider(EncryptionKey, EncryptionVector); - - #endregion - public DbSet Customers => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -25,6 +14,5 @@ public class WriteDbContext(DbContextOptions dbOptions) base.OnModelCreating(modelBuilder); modelBuilder.ApplyConfiguration(new CustomerConfiguration()); - modelBuilder.UseEncryption(_encryptionProvider); } } \ No newline at end of file diff --git a/src/Shop.Infrastructure/Data/Mappings/CustomerConfiguration.cs b/src/Shop.Infrastructure/Data/Mappings/CustomerConfiguration.cs index 8b17c58..8f34451 100644 --- a/src/Shop.Infrastructure/Data/Mappings/CustomerConfiguration.cs +++ b/src/Shop.Infrastructure/Data/Mappings/CustomerConfiguration.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.DataEncryption; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Shop.Domain.Entities.CustomerAggregate; using Shop.Infrastructure.Data.Extensions; @@ -36,8 +35,7 @@ internal class CustomerConfiguration : IEntityTypeConfiguration .Property(email => email.Address) .IsRequired() // NOT NULL .HasMaxLength(254) - .HasColumnName(nameof(Customer.Email)) - .IsEncrypted(); // Encryption + .HasColumnName(nameof(Customer.Email)); // Unique Index ownedNav diff --git a/src/Shop.Infrastructure/Shop.Infrastructure.csproj b/src/Shop.Infrastructure/Shop.Infrastructure.csproj index c8fdcc4..3a69b88 100644 --- a/src/Shop.Infrastructure/Shop.Infrastructure.csproj +++ b/src/Shop.Infrastructure/Shop.Infrastructure.csproj @@ -5,13 +5,10 @@ - - - diff --git a/src/Shop.PublicApi/Controllers/v1/CustomersController.cs b/src/Shop.PublicApi/Controllers/v1/CustomersController.cs index 193e3e7..d4f0a32 100644 --- a/src/Shop.PublicApi/Controllers/v1/CustomersController.cs +++ b/src/Shop.PublicApi/Controllers/v1/CustomersController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Net.Mime; using System.Threading.Tasks; +using Asp.Versioning; using MediatR; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; diff --git a/src/Shop.PublicApi/Program.cs b/src/Shop.PublicApi/Program.cs index 477a892..67861de 100644 --- a/src/Shop.PublicApi/Program.cs +++ b/src/Shop.PublicApi/Program.cs @@ -1,5 +1,6 @@ using System.Globalization; using System.IO.Compression; +using Asp.Versioning; using CorrelationId; using CorrelationId.DependencyInjection; using FluentValidation; @@ -41,15 +42,14 @@ builder.Services versioningOptions.ReportApiVersions = true; versioningOptions.AssumeDefaultVersionWhenUnspecified = true; }) - .AddVersionedApiExplorer(explorerOptions => + .AddApiExplorer(explorerOptions => { explorerOptions.GroupNameFormat = "'v'VVV"; explorerOptions.SubstituteApiVersionInUrl = true; - }) - .AddSwagger(); + }); +builder.Services.AddSwagger(); builder.Services.AddDataProtection(); - builder.Services.AddControllers() .ConfigureApiBehaviorOptions(behaviorOptions => { diff --git a/src/Shop.PublicApi/Shop.PublicApi.csproj b/src/Shop.PublicApi/Shop.PublicApi.csproj index 2d4d3f1..f4929b8 100644 --- a/src/Shop.PublicApi/Shop.PublicApi.csproj +++ b/src/Shop.PublicApi/Shop.PublicApi.csproj @@ -13,14 +13,14 @@ + + - - runtime; build; native; contentfiles; analyzers; buildtransitive