Click or drag to resize

ISettingsChange Method (SettingsKey, String)

Change the value of the specified AskiaPortal settings item.
It will not save the change in the database unless you explicitly call the Save method.

Namespace:  AskiaPortalCmn.Common
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
IReturnValue Change(
	SettingsKey key,
	string value
)

Parameters

key
Type: AskiaPortalCmn.CommonSettingsKey
AskiaPortal key of the settings item to obtain.
value
Type: SystemString
Value of the settings serialized as string.

Return Value

Type: IReturnValue
It return fail value, if the user in the context doesn't have enough permission to do this action.
Remarks
It will not save the change in the database unless you explicitly call the Save method.
Examples

Add or update AskiaPortal settings.

var context = ContextFactory.CreateByLoginAndPassword("username", "secret");
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
    Console.Error.Write(contextValidation.Exception.Message);
    return;
}

var user = context.User;
var userSettings = user.Settings;
var changeResult = userSettings.Change(SettingsKey.AllowConcurrentSessions, true.ToString());
if (changeResult.Success)
{
    Console.WriteLine("User settings `AllowConcurrentSessions` successfully changed.");
}
else
{
    Console.Error.WriteLine(changeResult.Exception.Message);
}

// To complete the action save the settings
var saveResult = userSettings.Save();
if (saveResult.Success)
{
    Console.WriteLine("User settings successfully saved!");
}
else
{
    Console.WriteLine(saveResult.Exception.Message);
}
See Also