示例#1
0
        private void SendEditCustomer(Delivery deliveryInfo)
        {
            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("ajax", "true"),
                new KeyValuePair <string, string>("method", "editCustomer"),
                new KeyValuePair <string, string>("email", email),
                new KeyValuePair <string, string>("newsletter", "1"),
                new KeyValuePair <string, string>("vat_number", ""),
                new KeyValuePair <string, string>("firstname", deliveryInfo.firstname),
                new KeyValuePair <string, string>("lastname", deliveryInfo.lastname),
                new KeyValuePair <string, string>("address1", deliveryInfo.address1),
                new KeyValuePair <string, string>("postcode", deliveryInfo.postcode),
                new KeyValuePair <string, string>("city", deliveryInfo.city),
                new KeyValuePair <string, string>("phone", deliveryInfo.phone),
                new KeyValuePair <string, string>("id_country", deliveryInfo.id_country),
                new KeyValuePair <string, string>("id_country_invoice", deliveryInfo.id_country),
                new KeyValuePair <string, string>("customer_lastname", deliveryInfo.lastname),
                new KeyValuePair <string, string>("customer_firstname", deliveryInfo.firstname),
                new KeyValuePair <string, string>("alias", deliveryInfo.alias),
                new KeyValuePair <string, string>("default_alias", "Moje adresa"),
                new KeyValuePair <string, string>("other", ""),
                new KeyValuePair <string, string>("is_new_customer", "0"),
                new KeyValuePair <string, string>("token", sessionToken)
            };

            httpClient.Post(orderUrl, parameters);
        }
示例#2
0
        private PersistentSessionHttpClient LoginToPizzaProvider(string username, string password)
        {
            var client = new PersistentSessionHttpClient();

            var loginPostForm = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("email", username),
                new KeyValuePair <string, string>("passwd", password),
                new KeyValuePair <string, string>("back", "identity"),
                new KeyValuePair <string, string>("SubmitLogin", "")
            };

            var response = client.Post(loginPage, loginPostForm);
            var content  = response.Content.ReadAsStringAsync().Result;

            // Failed to login - page was not redirected to identity page
            if (!content.Contains("<title>Identity - CarusoPizza</title>"))
            {
                throw new PizzaProviderException($"Failed to login user '{username}'. Check that password is correct, try to log via web on {loginPage}");
            }

            DebugContent.WriteToHtmlFile(content);

            return(client);
        }