diff --git a/Presentations/BuildingBlock.Presentation.API/Extensions/DefaultExtensions.cs b/Presentations/BuildingBlock.Presentation.API/Extensions/DefaultExtensions.cs index a224909..907e10a 100644 --- a/Presentations/BuildingBlock.Presentation.API/Extensions/DefaultExtensions.cs +++ b/Presentations/BuildingBlock.Presentation.API/Extensions/DefaultExtensions.cs @@ -1,4 +1,8 @@ using System.Text.Json.Serialization; +using BuildingBlock.Core.Application; +using BuildingBlock.Core.Domain; +using BuildingBlock.Infrastructure.EntityFrameworkCore; +using FluentValidation; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -6,8 +10,11 @@ namespace BuildingBlock.Presentation.API.Extensions; public static class DefaultExtensions { - public static IServiceCollection AddDefaultExtensions(this IServiceCollection services, - IConfiguration configuration) + public static async Task AddDefaultExtensions(this IServiceCollection services, IConfiguration configuration) + where TDbContext : BaseDbContext + where TApplicationAssemblyReference : ApplicationAssemblyReference + where TDomainAssemblyReference : DomainAssemblyReference { services .AddControllers() @@ -20,10 +27,25 @@ public static IServiceCollection AddDefaultExtensions(this IServiceCollection se .AddApplicationCors(configuration) .AddHttpContextAccessor() .AddCurrentUser() + .AddDatabase(configuration) + .AddMapper() + .AddCqrs() .AddDefaultOpenApi(configuration) .AddEventBus(configuration) - .AddInMemoryCache(configuration) - .AddEmail(configuration); + .AddValidatorsFromAssembly(typeof(TApplicationAssemblyReference).Assembly) + .AddInMemoryCache(configuration); + + services + .RegisterSeeders() + .RegisterServices() + .RegisterServices() + .RegisterDefaultRepositories() + .RegisterCustomRepositories() + .RegisterCachedRepositories() + .RegisterIntegrationEventHandlers() + .RegisterUnitOfWork(); + + await services.ApplyMigrationAsync(); return services; } diff --git a/Presentations/BuildingBlock.Presentation.API/Extensions/ModuleExtension.cs b/Presentations/BuildingBlock.Presentation.API/Extensions/DefaultModuleExtensions.cs similarity index 100% rename from Presentations/BuildingBlock.Presentation.API/Extensions/ModuleExtension.cs rename to Presentations/BuildingBlock.Presentation.API/Extensions/DefaultModuleExtensions.cs