Esempio n. 1
0
    public async System.Threading.Tasks.Task ListForms2Async()
    {
        var            tenantId = Guid.Parse(TenantId);
        FormDefinition form     = await this.client.CreateFormAsync(
            new CreateFormRequest
        {
            Name   = "TestForm",
            Fields = new List <FormFieldDefinition>
            {
                new FormFieldDefinition
                {
                    Name = "Name",
                    Type = "string",
                },
                new FormFieldDefinition
                {
                    Name = "Age",
                    Type = "int",
                },
            },
        },
            tenantId).ConfigureAwait(false);

        form.Should().NotBeNull();

        form = await this.client.GetFormAsync(tenantId, form.FormId).ConfigureAwait(false);

        form.Should().NotBeNull();

        FormSubmission submission = await this.client.SubmitFormAsync(
            form.FormId,
            new Dictionary <string, string>
        {
            ["Name"] = "Test",
            ["Age"]  = "30",
        },
            new Dictionary <string, HttpFile>
        {
            ["ProfilePicture"] = new HttpFile(File.OpenRead("350x350.png"), "test.png", "image/png"),
        },
            tenantId).ConfigureAwait(false);

        submission.Should().NotBeNull();

        submission = await this.client.GetSubmissionAsync(tenantId, form.FormId, submission.SubmissionId).ConfigureAwait(false);

        submission.Should().NotBeNull();

#pragma warning disable CA2000 // Dispose objects before losing scope
        HttpFile attachment = await this.client.GetSubmissionAttachmentAsync(form.FormId, submission.SubmissionId, "ProfilePicture", tenantId).ConfigureAwait(false);

#pragma warning restore CA2000 // Dispose objects before losing scope
        attachment.Should().NotBeNull();

        ICollection <FormDefinition> forms = await this.client.ListFormsAsync(tenantId).ConfigureAwait(false);
    }