using Microsoft.EntityFrameworkCore; using DigitalData.UserManager.Application.MappingProfiles; using DigitalData.UserManager.Application.Contracts; using DigitalData.UserManager.Application.Services; using DigitalData.UserManager.Infrastructure.Repositories; using DigitalData.UserManager.Infrastructure.Contracts; using DigitalData.Core.CultureServices; using DigitalData.Core.Contracts.Authentication.Services; using DigitalData.UserManager.Domain.Entities; using DigitalData.Core.Authentication.Services; var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); // Add API Versioning //builder.Services.AddApiVersioning(options => //{ // options.ApiVersionReader = new QueryStringApiVersionReader("v"); // options.AssumeDefaultVersionWhenUnspecified = true; // options.DefaultApiVersion = new ApiVersion(1, 0); // options.ReportApiVersions = true; //}); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DD_ECM_Connection"))); builder.Services.AddCors(options => { options.AddPolicy(name: "AllowAny", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); builder.Services.AddKeyTranslationService(); builder.Services.AddAutoMapper(typeof(UserMappingProfile).Assembly); builder.Services.AddAutoMapper(typeof(GroupMappingProfile).Assembly); builder.Services.AddAutoMapper(typeof(GroupOfUserMappingProfile).Assembly); builder.Services.AddAutoMapper(typeof(ModuleMappingProfile).Assembly); builder.Services.AddAutoMapper(typeof(ModuleOfUserMappingProfile).Assembly); builder.Services.AddAutoMapper(typeof(UserRepMappingProfile).Assembly); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped, ADService>(); var app = builder.Build(); var corsPolicy = app.Configuration["CorsPolicy"] ?? throw new InvalidOperationException("CorsPolicy configuration is missing in app settings."); app.UseCors(corsPolicy); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();