using MTWorkHR.Application; using MTWorkHR.Infrastructure; using MTWorkHR.Identity; using Microsoft.Extensions.Configuration; using MTWorkHR.Infrastructure.Data; using Microsoft.EntityFrameworkCore; using MTWorkHR.Core; using MTWorkHR.Core.Global; using MTWorkHR.Application.Middlewares; using MTWorkHR.Application.Services.Interfaces; using MTWorkHR.Application.Filters; using MTWorkHR.Application.StartupService; using Microsoft.AspNetCore.Mvc; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddDbContext(options => { options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value); }); var config = new AppSettingsConfiguration(); builder.Configuration.Bind(config); builder.Services.AddApplicationServices(config); builder.Services.AddInfrastructureServices(config); //builder.Services.AddPersistenceServices(builder.Configuration); builder.Services.AddIdentityServices(config); builder.Services.AddHostedService(); //builder.Services.AddControllers(); builder.Services.AddControllers(options => { //add filter by instance options.Filters.Add(new InputValidationActionFilter()); //add filter By the type options.Filters.Add(typeof(InputValidationActionFilter)); }); //disable default model validation, because we handle this in InputValidationActionFilter and LoggingMiddleware. builder.Services.Configure(options => { options.SuppressModelStateInvalidFilter = true; }); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure the HTTP request pipeline. // if (app.Environment.IsDevelopment()) // { app.UseSwagger(); app.UseSwaggerUI(); // } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.UseMiddleware(); app.MapControllers(); app.Run();