简体   繁体   English

在Angular的AspnetBoilerplate中从客户端更新/更改设置

[英]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. 使用Angular / .net Core模板的Asp.net Boilerplate,我看到“设置”名称空间中有一些客户端函数{get,getBoolean,getInt},可以很轻松地获取设置,但是我看不到任何有关更新这些设置的文档。

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

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

I was expecting to see similar set methods alongside the get methods. 我期待在get方法的旁边看到类似的set方法。 What am I missing or should I try to submit a PR for that functionality? 我缺少什么,还是应该尝试为此功能提交PR? 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. 当然,我可以更新用户服务并创建自己的函数来更新设置,但这似乎应该像get方法一样将其内置到框架中。

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 例如,一个用户可能想要配置UI并拥有一个布局设置,或者每个用户都有一个他们正在使用的帐户的设置...简而言之,例如Profile Provider: https : //docs.microsoft.com/en -us / DOTNET / API / system.web.profile.sqlprofileprovider?视图= 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() . 创建一个名为UserPreferencesAppService的应用程序服务,并添加类似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. PS:我把代码写在脑海上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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