IMethodResult Interface |
Namespace: AskiaCore
The IMethodResult type exposes the following members.
Name | Description | |
---|---|---|
Error |
Error that has been generated by the called method, it could be null when the called method succeed (Success is true). | |
Success |
Indicates if the method called was successfully executed
|
Create a new survey with one question
using AskiaCore; namespace MyApp { public class MyProgram { static void Main() { // Initialize the database connection string (Where the survey will be stored) Persistent.InitDatabaseConnection("connectionstring", DatabaseTypes.PORTAL); // Create a new context IContext context = ContextFactory.Create(); context.UserId = 1; context.SessionId = "xxxxx-xxxxx-xxxxx-xxxxxx"; context.LanguageId = 2057; // Edit the survey with this language (English) // Create a new survey ISurvey survey = SurveyFactory.Create(context); survey.Name = "MySurvey"; IMethodResult result = survey.SetDefaultLanguageId(2057); // English if (result.Success) { // Create the single closed question gender IQuestion gender = survey.Questions.Create(); gender.Shortcut = "gender"; gender.MainCaption ="What's your gender?"; gender.Type = QuestionType.Single; // Save all changes survey.SaveAll(); } // Release the database connection Persistent.EndDatabaseConnection(); } } }