change folder vor ab.web
This commit is contained in:
66
AB.WEB/Program.cs
Normal file
66
AB.WEB/Program.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using AB.Domain.Repositories;
|
||||
using AB.Persistence;
|
||||
using AB.Persistence.Repos;
|
||||
using AB.Services;
|
||||
using AB.Services.Abstractions;
|
||||
using AB_API.Middleware;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers().AddApplicationPart(typeof(AB.API.AssemblyReference).Assembly)
|
||||
.AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "AB-API",
|
||||
Version = "v1",
|
||||
Description = "An Api for the AB-Application"
|
||||
});
|
||||
|
||||
var xmlFilename = $"{typeof(AB.API.AssemblyReference).Assembly.GetName().Name}.xml";
|
||||
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<ICustomerService, CustomerService>();
|
||||
builder.Services.AddScoped<ICustomerRepository, CustomerRepository>();
|
||||
|
||||
builder.Services.AddScoped<ISupplierService, SupplierService>();
|
||||
builder.Services.AddScoped<ISupplierRepository, SupplierRepository>();
|
||||
|
||||
builder.Services.AddScoped<IUnitOfWork, UnitOfWork>();
|
||||
|
||||
builder.Services.AddDbContextPool<RepoDbContext>(builder =>
|
||||
{
|
||||
builder.UseInMemoryDatabase("test");
|
||||
});
|
||||
|
||||
builder.Services.AddTransient<ExceptionHandlingMiddleware>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user