Click or drag to resize

ISettingsChange Method (String, String, NullableGuid)

Change the value of the specified 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(
	string key,
	string value,
	Nullable<Guid> moduleGuid = null
)

Parameters

key
Type: SystemString
Key of the settings item to obtain.
value
Type: SystemString
Value of the settings serialized as string.
moduleGuid (Optional)
Type: SystemNullableGuid
GUID of the module that contains the settings item.
It uses the current module Guid if the value is null.

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 settings of the current module.

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("dontShowStartupPage", true.ToString());
if (changeResult.Success)
{
    Console.WriteLine("User preference `dontShowStartupPage` 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 preferences successfully saved!");
}
else
{
    Console.WriteLine(saveResult.Exception.Message);
}
See Also