Click or drag to resize

ContextFactoryCreateForRegistration Method

Creates a special restricted context of execution to register a user account.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static IContext CreateForRegistration(
	string apiKey = null
)

Parameters

apiKey (Optional)
Type: SystemString
Indicates the API key of the application that currently request a context. If null, we assume that the application in used is AskiaPortal.

Return Value

Type: IContext
A restricted context of execution
Remarks
The usage of this context will restrict many features of the API
It will basically only allows the creation a new user account and send emails for activation.
Examples

This example shows how to create a context to register a new user account.

using system;
using AskiaPortalCmn;

namespace MyApp 
{
    class Program
    {
         static void Main(string[] args)
         {
                var context = ContextFactory.CreateForRegistration();
                context.User.FirstName = "John";
                context.User.LastName = "Doe";
                context.User.Email = "johndoe@anonymous.com";
                var saveResult = context.User.Save();
                if (saveResult.Success)
                {
                    Console.WriteLine("The account for the user `{0} {1}` was successfully created. An email has been sent to `{2}`",
                                        context.User.FirstName, context.User.LastName, context.User.Email);
                }
                else
                {
                    Console.Error.WriteLine("Unable to create the user account");
                    Console.Error.Write(saveResult.Exception.Message);
                }
         }
    }
}
See Also