Program.cs 1.2 KB

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