Click or drag to resize

UserFactoryNewUserForRegistration Method

Create a new user for registration

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static IUser NewUserForRegistration(
	IContext context
)

Parameters

context
Type: AskiaPortalCmnIContext
Context of execution

Return Value

Type: IUser
Return a new empty user
Examples

Register a new user

var context = ContextFactory.CreateForRegistration();   
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
    throw contextValidation.Exception;
}
var user = UserFactory.NewUserForRegistration(context);
user.FirstName = "John";
user.LastName = "Doe";
user.Login = "JohnDoe";
user.Email = "johndoe@anonymous.com";
var saveResult = user.Save();
if (saveResult.Success)
{
    Console.WriteLine("The user `{0} {1}` (Id={2}) was successfully saved",
                                    user.FirstName, user.LastName, user.Id);
}
else
{
    Console.Error.WriteLine("Unable to register the new user");
    Console.Error.Write(saveResult.Exception.Message);
}
See Also