public static IServiceCollection AddCipasEntityFramework(this IServiceCollection services, CipasSqlConfiguration cipasSqlConfiguration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddSingleton(cipasSqlConfiguration ?? throw new ArgumentNullException(nameof(cipasSqlConfiguration))); services.AddDbContext <CipasContext>(options => options.UseSqlServer(cipasSqlConfiguration.ConnectionString)); services.AddScoped <ICipaReadOnlyRepository, CipaRepository>(); services.AddScoped <ICipaWriteOnlyRepository, CipaRepository>(); services.AddScoped <IReuniaoReadOnlyRepository, ReuniaoRepository>(); services.AddScoped <IReuniaoWriteOnlyRepository, ReuniaoRepository>(); return(services); }
public static IServiceCollection AddCipasQueries(this IServiceCollection services, CipasSqlConfiguration cipasSqlConfiguration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddSingleton(cipasSqlConfiguration ?? throw new ArgumentNullException(nameof(cipasSqlConfiguration))); services.AddTransient <CipasQueryContext>(); services.AddMediatR(typeof(CipasQueryContext).Assembly); return(services); }