Click or drag to resize

SurveyFactoryNewSurvey Method

Create a new empty instance of survey

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

Parameters

context
Type: AskiaPortalCmnIContext
Context of execution

Return Value

Type: ISurvey
Return a new empty survey or null if the user in the context doesn't have enough right to create a survey
Examples

Create a new survey and save it

var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));   
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
    throw contextValidation.Exception;
}

var survey = SurveyFactory.NewSurvey(context);
if (survey == null)
{
    Console.Error.WriteLine("Could not create a new survey");
    return;
}
survey.Name = "My new survey";
var saveResult = survey.Save();
if (saveResult.Success)
{
    Console.WriteLine("The survey `{0}` (Id={1}) was successfully saved",
                                    survey.Name, survey.Id);
}
else
{
    Console.Error.Write(saveResult.Exception.Message);
}
See Also