AVS-Carton-Shipment-Verifier/Program.cs

40 lines
1.2 KiB
C#

using AVSCartonShipmentVerifier.Configuration;
using AVSCartonShipmentVerifier.Data;
using AVSCartonShipmentVerifier.Repositories;
using AVSCartonShipmentVerifier.Services;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddOptions<CartonVerificationOptions>()
.Bind(builder.Configuration.GetSection(CartonVerificationOptions.SectionName))
.ValidateDataAnnotations()
.ValidateOnStart();
builder.Services.AddControllersWithViews();
builder.Services.AddSingleton<IScanHistoryStore, InMemoryScanHistoryStore>();
builder.Services.AddScoped<IVerificationDbConnectionFactory, VerificationDbConnectionFactory>();
builder.Services.AddScoped<ICartonVerificationRepository, CartonVerificationRepository>();
builder.Services.AddScoped<IShipmentVerificationService, ShipmentVerificationService>();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.MapStaticAssets();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}")
.WithStaticAssets();
app.Run();