86 lines
3.1 KiB
C#
86 lines
3.1 KiB
C#
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.Application;
|
|
using System.DirectoryServices;
|
|
using DigitalData.UserManager.API;
|
|
|
|
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<DDECMDbContext>(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.AddAutoMapper(typeof(DirectoryMappingProfile).Assembly);
|
|
|
|
builder.Services.AddScoped<IUserRepository, UserRepository>();
|
|
builder.Services.AddScoped<IGroupRepository, GroupRepository>();
|
|
builder.Services.AddScoped<IGroupOfUserRepository, GroupOfUserRepository>();
|
|
builder.Services.AddScoped<IModuleRepository, ModuleRepository>();
|
|
builder.Services.AddScoped<IModuleOfUserRepository, ModuleOfUserRepository>();
|
|
builder.Services.AddScoped<IUserRepRepository, UserRepRepository>();
|
|
|
|
builder.Services.AddScoped<IUserService, UserService>();
|
|
builder.Services.AddScoped<IGroupService, GroupService>();
|
|
builder.Services.AddScoped<IGroupOfUserService, GroupOfUserService>();
|
|
builder.Services.AddScoped<IModuleService, ModuleService>();
|
|
builder.Services.AddScoped<IModuleOfUserService, ModuleOfUserService>();
|
|
builder.Services.AddScoped<IUserRepService, UserRepService>();
|
|
|
|
builder.Services.AddDirectoryService();
|
|
|
|
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(); |