39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using RhSolutions.Models;
|
|
using RhSolutions.Api.Services;
|
|
using RhSolutions.Api.Middleware;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
string dbHost = builder.Configuration["DB_HOST"],
|
|
dbPort = builder.Configuration["DB_PORT"],
|
|
dbName = builder.Configuration["DB_DATABASE"],
|
|
dbUser = builder.Configuration["DB_USER"],
|
|
dbPassword = builder.Configuration["DB_PASSWORD"];
|
|
|
|
string connectionString = builder.Configuration["ConnectionsStrings:RhSolutionsLocal"]
|
|
?? $"Host={dbHost};Port={dbPort};Database={dbName};Username={dbUser};Password={dbPassword}";
|
|
|
|
builder.Services.AddDbContext<RhSolutionsContext>(opts =>
|
|
{
|
|
opts.UseNpgsql(connectionString);
|
|
if (builder.Environment.IsDevelopment())
|
|
{
|
|
opts.EnableSensitiveDataLogging(true);
|
|
}
|
|
});
|
|
builder.Services.AddScoped<IPricelistParser, ClosedXMLParser>()
|
|
.AddScoped<IProductTypePredicter, ProductTypePredicter>()
|
|
.AddSingleton<ProductQueryModifierFactory>();
|
|
builder.Services.AddControllers();
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapControllers();
|
|
app.UseMiddleware<QueryModifier>();
|
|
|
|
var context = app.Services.CreateScope().ServiceProvider
|
|
.GetRequiredService<RhSolutionsContext>();
|
|
|
|
app.Run();
|