Program.cs 1.2 KB

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