Пример #1
0
        private void btnAccountCreatePassengerAndSmugglerCustomData_Click(object sender, EventArgs e)
        {
            var newPassenger1 = new PassengerCustomData()
            {
                Id = new Guid(),
                FirstName = "Han",
                LastName = "Solo",
                Birthdate = Convert.ToDateTime("2015-03-02"),
                Address1 = "1234 Hariison Ford Road",
                Address2 = "",
                PostalCode = "12345",
                City = "Corellia",
                State = "California",
                Phone = "1234567890",
                Email = "*****@*****.**"
            };

            var newPassenger2 = new PassengerCustomData()
            {
                Id = new Guid(),
                FirstName = "Chewbacca",
                LastName = "Wooky",
                Birthdate = Convert.ToDateTime("2015-03-02"),
                Address1 = "1234 Peter Mayhew Road",
                Address2 = "",
                PostalCode = "12345",
                City = "Kashyyyk",
                State = "California",
                Phone = "1234567890",
                Email = "*****@*****.**"
            };

            var newPassenger3 = new PassengerCustomData()
            {
                Id = new Guid(),
                FirstName = "Leia",
                LastName = "Organa",
                Birthdate = Convert.ToDateTime("2015-03-02"),
                Address1 = "1234 Carrie Fisher Road",
                Address2 = "",
                PostalCode = "12345",
                City = "Alderaan",
                State = "California",
                Phone = "1234567890",
                Email = "*****@*****.**"
            };

            var customDataList = new[] { newPassenger1, newPassenger2, newPassenger3 }.ToList();

            var customDataPassengerData = new CustomPassengerData()
            {
                Passengers = customDataList
            };

            var smugglerCredentials = new SmugglingCredentialCustomData()
            {
                LicenseNumber = "700423F4A4504E8A9955C88A8322C284"
            };

            var customDataSmugglerData = new CustomSmugglerData()
            {
                SmugglingCredential = smugglerCredentials
            };

            var customData = new { PassengerData = customDataPassengerData, SmugglerData = customDataSmugglerData };

            try
            {
                StormpathAccount<StormpathCustomData> stormpathAccount = stormPath.CreateAccount<StormpathCustomData>(txtEmail.Text, txtPassword.Text, txtFullName.Text, txtGivenName.Text, txtSurname.Text, txtStatus.Text, customData, GetExpandedSelections());

                if (stormpathAccount.href != null)
                {
                    txtAccountResult.Text = stormpathAccount.content;
                    txtAccountEmailResponse.Text = stormpathAccount.email;
                    txtAccountFullNameResponse.Text = stormpathAccount.fullName;
                    txtAccountGUIDResponse.Text = stormpathAccount.href.Split('/').Last();
                    txtAccountGivenNameResponse.Text = stormpathAccount.givenName;
                    txtAccountPasswordResponse.Text = stormpathAccount.password;
                    txtAccountStatusResponse.Text = stormpathAccount.status;
                    txtAccountSurNameResponse.Text = stormpathAccount.surname;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void btnCreateWithSmugglerCustomData_Click(object sender, EventArgs e)
        {
            //can use an anonymous type for serialization, but then deserialization doesn't work. So we use a custom type.
            var smugglerCredentials = new SmugglingCredentialCustomData()
            {
                LicenseNumber = "700423F4A4504E8A9955C88A8322C284"
            };

            var customDataSmugglerData = new CustomSmugglerData()
            {
                SmugglingCredential = smugglerCredentials
            };

            var customData = new
            {
                SmugglerData = customDataSmugglerData
            };

            try
            {
                StormpathAccount<StormpathCustomData> stormpathAccount = stormPath.CreateAccount<StormpathCustomData>(txtEmail.Text, txtPassword.Text, txtFullName.Text, txtGivenName.Text, txtSurname.Text, txtStatus.Text, customData, GetExpandedSelections());

                if (stormpathAccount.href != null)
                {
                    txtAccountResult.Text = stormpathAccount.content;
                    txtAccountEmailResponse.Text = stormpathAccount.email;
                    txtAccountFullNameResponse.Text = stormpathAccount.fullName;
                    txtAccountGUIDResponse.Text = stormpathAccount.href.Split('/').Last();
                    txtAccountGivenNameResponse.Text = stormpathAccount.givenName;
                    txtAccountPasswordResponse.Text = stormpathAccount.password;
                    txtAccountStatusResponse.Text = stormpathAccount.status;
                    txtAccountSurNameResponse.Text = stormpathAccount.surname;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }