2022-12-14 09:53:10 +03:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-05-11 07:55:26 +03:00
|
|
|
using RhSolutions.Models;
|
2022-12-14 09:53:10 +03:00
|
|
|
using RhSolutions.Api.Services;
|
2023-09-19 14:56:55 +03:00
|
|
|
using RhSolutions.Api.Middleware;
|
2023-10-10 22:26:16 +03:00
|
|
|
using RhSolutions.QueryModifiers;
|
2022-12-14 09:53:10 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
2023-09-19 14:56:55 +03:00
|
|
|
builder.Services.AddScoped<IPricelistParser, ClosedXMLParser>()
|
|
|
|
.AddScoped<IProductTypePredicter, ProductTypePredicter>()
|
|
|
|
.AddSingleton<ProductQueryModifierFactory>();
|
2022-12-14 09:53:10 +03:00
|
|
|
builder.Services.AddControllers();
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
app.MapControllers();
|
2023-09-19 14:56:55 +03:00
|
|
|
app.UseMiddleware<QueryModifier>();
|
2022-12-14 09:53:10 +03:00
|
|
|
|
|
|
|
var context = app.Services.CreateScope().ServiceProvider
|
|
|
|
.GetRequiredService<RhSolutionsContext>();
|
|
|
|
|
|
|
|
app.Run();
|