Alle Entitäten wurden mit Attributen erstellt und zu EFCore DBContex hinzugefügt.
This commit is contained in:
@@ -7,73 +7,78 @@ using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using EnvelopeGenerator.Infrastructure.Repositories;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using Quartz;
|
||||
using NLog.Web;
|
||||
|
||||
namespace EnvelopeGenerator.Web
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Info("Logging initialized!");
|
||||
try
|
||||
{
|
||||
public class Program
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Host.UseNLog();
|
||||
|
||||
// Add base services
|
||||
builder.Services.AddScoped<DatabaseService>();
|
||||
|
||||
// Add higher order services
|
||||
builder.Services.AddScoped<EnvelopeService>();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews().AddJsonOptions(q =>
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// Prevents serialization error when serializing SvgBitmap in EnvelopeReceiver
|
||||
q.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||
});
|
||||
|
||||
// Add base services
|
||||
builder.Services.AddSingleton<LoggingService>();
|
||||
builder.Services.AddScoped<DatabaseService>();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
// Add higher order services
|
||||
builder.Services.AddScoped<EnvelopeService>();
|
||||
builder.Services.AddKeyTranslationService();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews().AddJsonOptions(q =>
|
||||
{
|
||||
// Prevents serialization error when serializing SvgBitmap in EnvelopeReceiver
|
||||
q.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||
});
|
||||
//AddEF Core dbcontext
|
||||
var connStr = builder.Configuration["Config:ConnectionString"];
|
||||
builder.Services.AddDbContext<EGDbContext>(options =>
|
||||
options.UseSqlServer(connStr));
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
//Inject CRUD Service and repositories
|
||||
builder.Services.AddScoped<IConfigRepository, ConfigRepository>();
|
||||
builder.Services.AddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
|
||||
|
||||
builder.Services.AddKeyTranslationService();
|
||||
builder.Services.AddScoped<IConfigService, ConfigService>();
|
||||
builder.Services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
||||
|
||||
//AddEF Core dbcontext
|
||||
var connStr = builder.Configuration["Config:ConnectionString"];
|
||||
builder.Services.AddDbContext<EGDbContext>(options =>
|
||||
options.UseSqlServer(connStr));
|
||||
//Auto mapping profiles
|
||||
builder.Services.AddAutoMapper(typeof(BasicDtoMappingProfile).Assembly);
|
||||
|
||||
//Inject CRUD Service and repositories
|
||||
builder.Services.AddScoped<IConfigRepository, ConfigRepository>();
|
||||
builder.Services.AddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
|
||||
var app = builder.Build();
|
||||
|
||||
builder.Services.AddScoped<IConfigService, ConfigService>();
|
||||
builder.Services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
||||
|
||||
//Auto mapping profiles
|
||||
builder.Services.AddAutoMapper(typeof(BasicDtoMappingProfile).Assembly);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Stopped program because of exception");
|
||||
throw;
|
||||
}
|
||||
Reference in New Issue
Block a user