|
@@ -38,7 +38,7 @@ var config = new AppSettingsConfiguration();
|
|
|
// Add services to the container.
|
|
|
builder.Services.AddDbContext<HRDataContext>(options =>
|
|
|
{
|
|
|
- options.UseSqlServer(config.ConnectionStrings.LocalConnectionString);
|
|
|
+ options.UseSqlServer(config.ConnectionStrings.MTWorkHRConnectionString);
|
|
|
// options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value);
|
|
|
});
|
|
|
|
|
@@ -106,6 +106,11 @@ builder.Services.ConfigureReportingServices(configurator => {
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
//builder.Services.AddSwaggerGen();
|
|
|
//--------------------------
|
|
|
+builder.Services.AddSignalR(options =>
|
|
|
+{
|
|
|
+ options.EnableDetailedErrors = true;
|
|
|
+});
|
|
|
+
|
|
|
builder.Services.AddSwaggerGen(swagger =>
|
|
|
{
|
|
|
//This is to apply global headers for all requests
|
|
@@ -152,10 +157,7 @@ builder.Services.AddSwaggerGen(swagger =>
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
-builder.Services.AddSignalR(options =>
|
|
|
-{
|
|
|
- options.EnableDetailedErrors = true;
|
|
|
-});
|
|
|
+
|
|
|
//--------------------------
|
|
|
var app = builder.Build();
|
|
|
|
|
@@ -168,7 +170,11 @@ app.UseSwagger();
|
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.API v1"));
|
|
|
// }
|
|
|
|
|
|
+
|
|
|
+app.UseRouting(); // <-- Add UseRouting() here
|
|
|
+
|
|
|
app.UseCors(x => x
|
|
|
+ .WithOrigins("https://api.mtwork.com", "https://mtworkhrclient.azurewebsites.net", "http://localhost:4200/") // Allowed origin
|
|
|
.AllowAnyMethod()
|
|
|
.AllowAnyHeader()
|
|
|
.SetIsOriginAllowed(origin =>
|
|
@@ -176,21 +182,20 @@ app.UseCors(x => x
|
|
|
.AllowCredentials()); // allow credentials
|
|
|
|
|
|
|
|
|
-//app.MapPost("broadcast", async (string message, IHubContext<ChatHub, IChatClient> context) =>
|
|
|
-//{
|
|
|
-// await context.Clients.All.ReceiveMessage(message);
|
|
|
-// return Results.NoContent();
|
|
|
-//});
|
|
|
|
|
|
-//app.UseEndpoints(endpoints =>
|
|
|
-//{
|
|
|
-// endpoints.MapHub<ChatHub>("/chatHub");
|
|
|
-//});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
app.UseHttpsRedirection();
|
|
|
app.UseAuthentication();
|
|
|
app.UseAuthorization();
|
|
|
+app.UseEndpoints(endpoints =>
|
|
|
+{
|
|
|
+ endpoints.MapHub<ChatHub>("/chatHub"); // Map your SignalR hub
|
|
|
+});
|
|
|
app.UseMiddleware<LoggingMiddleware>();
|
|
|
app.MapControllers();
|
|
|
-app.MapHub<ChatHub>("/chatHub");
|
|
|
+//app.MapHub<ChatHub>("/chatHub");
|
|
|
|
|
|
app.Run();
|