UserFactoryNewUserForRegistration Method |
Namespace: AskiaPortalCmn
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); }