|
@@ -13,20 +13,33 @@ using Microsoft.AspNetCore.Mvc.Controllers;
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
using MTWorkHR.API.Swagger;
|
|
|
using Azure.Storage.Blobs;
|
|
|
+using Moq;
|
|
|
+
|
|
|
+
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using MTWorkHR.API.Chat;
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
+
|
|
|
+if (OperatingSystem.IsLinux())
|
|
|
+{
|
|
|
+ builder.Configuration.AddJsonFile("appsettings.Linux.json", optional: true, reloadOnChange: true);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
var config = new AppSettingsConfiguration();
|
|
|
|
|
|
builder.Services.AddDbContext<HRDataContext>(options =>
|
|
|
{
|
|
|
- options.UseSqlServer(config.ConnectionStrings.LocalConnectionString);
|
|
|
-
|
|
|
+ options.UseSqlServer(config.ConnectionStrings.MTWorkHRConnectionString);
|
|
|
+
|
|
|
});
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
builder.Configuration.Bind(config);
|
|
|
builder.Services.AddApplicationServices(config);
|
|
|
builder.Services.AddInfrastructureIdentityServices(config);
|
|
@@ -34,7 +47,28 @@ builder.Services.AddInfrastructureIdentityServices(config);
|
|
|
|
|
|
builder.Services.AddHostedService<DbMigrationService>();
|
|
|
|
|
|
-builder.Services.AddSingleton(x => new BlobServiceClient(config.ConnectionStrings.BlobConnectionString));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if (builder.Environment.IsDevelopment())
|
|
|
+{
|
|
|
+ var mockBlobServiceClient = new Mock<BlobServiceClient>();
|
|
|
+
|
|
|
+
|
|
|
+ var mockBlobContainerClient = new Mock<BlobContainerClient>();
|
|
|
+
|
|
|
+
|
|
|
+ mockBlobServiceClient
|
|
|
+ .Setup(x => x.GetBlobContainerClient(It.IsAny<string>()))
|
|
|
+ .Returns(mockBlobContainerClient.Object);
|
|
|
+
|
|
|
+ builder.Services.AddSingleton(mockBlobServiceClient.Object);
|
|
|
+}
|
|
|
+else
|
|
|
+{
|
|
|
+
|
|
|
+ builder.Services.AddSingleton(x => new BlobServiceClient(config.ConnectionStrings.BlobConnectionString));
|
|
|
+}
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers(options =>
|
|
@@ -117,7 +151,7 @@ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.AP
|
|
|
app.UseCors(x => x
|
|
|
.AllowAnyMethod()
|
|
|
.AllowAnyHeader()
|
|
|
- .SetIsOriginAllowed(origin =>
|
|
|
+ .SetIsOriginAllowed(origin =>
|
|
|
true)
|
|
|
.AllowCredentials());
|
|
|
|