Skip to content

Commit

Permalink
add if for whitelabel config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Oct 26, 2023
1 parent e5be6e6 commit b2e16ad
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Linq;
using System.Net;
using System.Net.Mime;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

Expand Down Expand Up @@ -109,8 +110,11 @@ public static async Task Build<TContext>(this IApplicationBuilder app)
var dbbuilder = new DatabaseCreator();
using var context = scope.ServiceProvider.GetRequiredService<TContext>();
dbbuilder.Initialize(context);
using var uow = scope.ServiceProvider.GetRequiredService<IUnitOfWork>() as UnitOfWork;
await uow.Initialize(MicroserviceName, config.GetValue<string>(ConfigName), typeof(TContext)).ConfigureAwait(false);
if (WhiteLabelRoute.HasValue() || ConfigName.HasValue())
{
using var uow = scope.ServiceProvider.GetRequiredService<IUnitOfWork>() as UnitOfWork;
await uow.Initialize(MicroserviceName, config.GetValue<string>(ConfigName), typeof(TContext)).ConfigureAwait(false);
}
}
var build = app.Build();
app.Run(build);
Expand Down Expand Up @@ -179,7 +183,11 @@ public static async Task<WebApplication> Build<TContext>(this WebApplicationBuil
using var context = scope.ServiceProvider.GetRequiredService<TContext>();
dbbuilder.Initialize(context);
using var uow = scope.ServiceProvider.GetRequiredService<IUnitOfWork>() as UnitOfWork;
await uow.Initialize(MicroserviceName, WhiteLabelRoute ?? config.GetValue<string>(ConfigName), typeof(TContext)).ConfigureAwait(false);
if (WhiteLabelRoute.HasValue() || ConfigName.HasValue())
{
var value = WhiteLabelRoute ?? config.GetValue<string>(ConfigName);
await uow.Initialize(MicroserviceName, WhiteLabelRoute ?? config.GetValue<string>(ConfigName), typeof(TContext)).ConfigureAwait(false);
}
}
return build;
}
Expand Down

0 comments on commit b2e16ad

Please sign in to comment.