Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "qstamps"

Yeah! I am able to solve that challenge.

I am sharing the step, hope it will help someone else.

File 1: MyProject/aspnet-core/src/MyProject.Web.Core/UiCustomization/Metronic/UiThemeCustomizerBase.cs

    protected async Task<T> GetSettingValueForUserAsync<T>(string settingName, int? tenantId, long userId) where T : struct
{
    return (await SettingManager.GetSettingValueForUserAsync(ThemeName + "." + settingName, tenantId ,userId)).To<T>();
}
protected async Task<string> GetSettingValueForUserAsync(string settingName, int? tenantId, long userId)
{
    return await SettingManager.GetSettingValueForUserAsync(ThemeName + "." + settingName, tenantId, userId);
}

File 2: MyProject/aspnet-core/src/MyProject.Web.Core/UiCustomization/Metronic/ThemeDefaultUiCustomizer.cs N.B: Need to done for every Theme--UiCustomizer.cs

    public async Task<UiCustomizationSettingsDto> GetUiSettings(int? tenantId, long? userId)
{
    var settings = new UiCustomizationSettingsDto
    {
        BaseSettings = new ThemeSettingsDto
        {
            Layout = new ThemeLayoutSettingsDto
            {
                //DarkMode = await GetSettingValueAsync<bool>(AppSettings.UiManagement.DarkMode)
                DarkMode = await GetSettingValueForUserAsync<bool>(AppSettings.UiManagement.DarkMode, tenantId, userId > 0 ? (long) userId : 0)
            },
            SubHeader = new ThemeSubHeaderSettingsDto
            {
                FixedSubHeader = true,
                //SubheaderStyle = await GetSettingValueAsync(AppSettings.UiManagement.SubHeader.Style),
               SubheaderStyle = await GetSettingValueForUserAsync(AppSettings.UiManagement.SubHeader.Style, tenantId, userId 0 ? (long)userId : 0),
                ContainerStyle = "subheader py-2 py-lg-4 subheader-solid toolbar"
            },
            ....
    return settings;
}

File 3: MyProject/aspnet-core/src/MyProject.Application/UiCustomization/IUiCustomizer.cs

    Task<UiCustomizationSettingsDto> GetUiSettings(***int? tenantId, long? userId***);

File 4: MyProject/aspnet-core/src/MyProject.Application/Configuration/UiCustomizationSettingsAppService.cs

    public async Task<List<ThemeSettingsDto>> GetUiManagementSettings()
{
    var settings = new List<ThemeSettingsDto>();
    var themeCustomizers = _iocResolver.ResolveAll<IUiCustomizer>();

    foreach (var themeUiCustomizer in themeCustomizers)
    {
        var themeSettings = await themeUiCustomizer.GetUiSettings(***AbpSession.TenantId, AbpSession.UserId***);
        settings.Add(themeSettings.BaseSettings);
    }

    return settings;
}

File 5: MyProject/aspnet-core/src/MyProject.Application/Sessions/SessionAppService.cs

    public async Task<GetCurrentLoginInformationsOutput> GetCurrentLoginInformations()
{
    .....
        var uiCustomizer = await _uiThemeCustomizerFactory.GetCurrentUiCustomizer();
        output.Theme = await uiCustomizer.GetUiSettings(***AbpSession.TenantId, AbpSession.UserId***);
        ......
}
Showing 1 to 1 of 1 entries