Program.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using MTWorkHR.Application;
  2. using MTWorkHR.Infrastructure;
  3. using MTWorkHR.Identity;
  4. using Microsoft.Extensions.Configuration;
  5. using MTWorkHR.Infrastructure.Data;
  6. using Microsoft.EntityFrameworkCore;
  7. using MTWorkHR.Core;
  8. var builder = WebApplication.CreateBuilder(args);
  9. // Add services to the container.
  10. builder.Services.AddDbContext<HRDataContext>(options => {
  11. options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value);
  12. });
  13. var config = new AppSettingsConfiguration();
  14. builder.Configuration.Bind(config);
  15. builder.Services.AddApplicationServices(config);
  16. builder.Services.AddInfrastructureServices(builder.Configuration);
  17. builder.Services.AddPersistenceServices(builder.Configuration);
  18. builder.Services.AddIdentityServices(config);
  19. builder.Services.AddControllers();
  20. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  21. builder.Services.AddEndpointsApiExplorer();
  22. builder.Services.AddSwaggerGen();
  23. var app = builder.Build();
  24. // Configure the HTTP request pipeline.
  25. if (app.Environment.IsDevelopment())
  26. {
  27. app.UseSwagger();
  28. app.UseSwaggerUI();
  29. }
  30. app.UseHttpsRedirection();
  31. app.UseAuthentication();
  32. app.UseAuthorization();
  33. app.MapControllers();
  34. app.Run();