This commit is contained in:
2023-07-23 20:27:23 +03:00
parent d0cdaa85b6
commit 96eca795ab
62 changed files with 2934 additions and 847 deletions
+36 -2
View File
@@ -37,10 +37,14 @@ using Identity.Configure;
using Infrastructure;
using Microsoft.Extensions.Logging.Console;
using IdentityServer4.Services;
using Models.Account;
using MyOffice.Services.Currency;
using Services.Account;
using Services.Item;
using MyOffice.Services.Dashboard;
using Services.Account.Domain;
using MyOffice.Services.Identity;
using AutoMapper;
public class Program
{
@@ -92,6 +96,10 @@ public class Program
AddIdentityServices(builder);
builder.Services.AddScoped<IContextProvider, ContextProvider>();
AddMapping(builder);
AddRepositories(builder);
AddBusinessServices(builder);
@@ -205,6 +213,20 @@ public class Program
}
}
private static void AddMapping(WebApplicationBuilder builder)
{
builder.Services.AddSingleton(provider => new MapperConfiguration(cfg =>
{
cfg.AddProfile(new AccountMappingProfile());
cfg.AddProfile(new ViewModelProfile());
cfg.AddProfile(new AccountViewModelProfile(provider.CreateScope().ServiceProvider.GetService<IContextProvider>()!));
}).CreateMapper());
//builder.Services.AddAutoMapper(typeof(AccountMappingProfile));
//builder.Services.AddAutoMapper(typeof(AccountViewModelProfile));
//builder.Services.AddAutoMapper(typeof(ViewModelProfile));
}
private static void AddRepositories(WebApplicationBuilder builder)
{
builder.Services.AddScoped<IUserRepository, UserRepository>();
@@ -216,6 +238,7 @@ public class Program
builder.Services.AddScoped<IAccountCategoryRepository, AccountCategoryRepository>();
builder.Services.AddScoped<IAccountRepository, AccountRepository>();
builder.Services.AddScoped<IAccountAccessRepository, AccountAccessRepository>();
builder.Services.AddScoped<IAccountAccountCategoryRepository, AccountAccountCategoryRepository>();
builder.Services.AddScoped<IItemCategoryRepository, ItemCategoryRepository>();
@@ -274,9 +297,20 @@ public class Program
{
_firstRequest = false;
// set real frontend host
globalSettings = ctx.RequestServices.GetRequiredService<GlobalSettings>();
globalSettings.Host = GetFrontendHost(ctx, logger);
var configuration = ctx.RequestServices.GetRequiredService<IConfiguration>();
var frontEndHost = configuration.GetValue<string>("FrontEnd:Host");
var isDynamicFrontEndHost = frontEndHost.IsMissing();
if (!isDynamicFrontEndHost)
{
globalSettings.Host = frontEndHost;
}
else
{
// set real frontend host
globalSettings.Host = GetFrontendHost(ctx, logger);
}
// update identity server
var options = ctx.RequestServices.GetRequiredService<IdentityServerOptions>();