简体   繁体   中英

Updating / Changing settings from client side in AspnetBoilerplate with Angular

With Asp.net Boilerplate using the Angular / .net Core template I see there are a few client side functions {get, getBoolean, getInt} in the "setting" namespace that make it quite easy to get the settings but I do not see any documentation on updating those settings.

var currentColor = abp.setting.get("SiteColorPreference");

https://aspnetboilerplate.com/Pages/Documents/Setting-Management

I was expecting to see similar set methods alongside the get methods. What am I missing or should I try to submit a PR for that functionality? Seems quite odd to have only getters and no setters.

Of course I can update the user service and create my own function to update the settings but that seems like it should be built into the framework just like the get methods.

Maybe this is not the correct place but the goal of the question is I want to utilize a local store for user variables. For instance a user might want to configure the UI and have a layout setting or each user has a setting for which account they are working on... in a nutshell something like Profile Provider: https://docs.microsoft.com/en-us/dotnet/api/system.web.profile.sqlprofileprovider?view=netframework-4.7.2

You need to create Application Service for your requirement. Let's investigate it for updating a user theme selection.

Create an application service called UserPreferencesAppService and add a method like UpdateMyThemeId() . And in your method set user's theme like below;

 public class UserPreferencesAppService: ApplicationService {

    const string AppPermissions.Pages_User_Settings = "AppPermissions.Pages.User.Settings"

    [AbpAuthorize(AppPermissions.Pages_User_Settings)]
    private async Task UpdateMyThemeId(string themeId)
    {
           await SettingManager.ChangeSettingForUserAsync(user, "User.Theme.Selection", themeId);

    }
 }

PS: I wrote the code on top of my head.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM