public static IServiceCollection AddOrganizacoesQueries(this IServiceCollection services, OrganizacoesSqlConfiguration coreBusinessSqlConfiguration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddSingleton(coreBusinessSqlConfiguration ?? throw new ArgumentNullException(nameof(coreBusinessSqlConfiguration))); services.AddTransient <OrganizacoesQueryContext>(); services.AddMediatR(typeof(OrganizacoesQueryContext).Assembly); return(services); }
public static IServiceCollection AddOrganizacoesEntityFramework(this IServiceCollection services, OrganizacoesSqlConfiguration coreBusinessSqlConfiguration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddSingleton(coreBusinessSqlConfiguration ?? throw new ArgumentNullException(nameof(coreBusinessSqlConfiguration))); services.AddDbContext <OrganizacoesContext>(options => options.UseSqlServer(coreBusinessSqlConfiguration.ConnectionString)); services.AddScoped <IEstabelecimentoReadOnlyRepository, EstabelecimentoRepository>(); services.AddScoped <IEstabelecimentoWriteOnlyRepository, EstabelecimentoRepository>(); return(services); }