// Sends orders to a shipping service endpoint dependent on the specified carrier
        private static async Task <IEnumerable <ItemTrackingDetail> > PostToCarrierAsync(CarrierType carrierType, Order[] orders)
        {
            var shipDetails = CreateShipDetails(orders);

            Console.WriteLine("Sending {0} orders to {1}.", orders.Length, carrierType);

            var client   = new System.Net.Http.HttpClient();
            var response = await client.PostAsync("http://localhost:9099/api/" + carrierType.ToString(), shipDetails, new JsonMediaTypeFormatter());

            if (!response.IsSuccessStatusCode)
            {
                throw new ApplicationException("Exception in shipping processor (" + carrierType + "): " + response.ReasonPhrase);
            }

            var results = await response.Content.ReadAsAsync <List <ItemTrackingDetail> >();

            return(results);
        }
Esempio n. 2
0
        private string GetCarrierText(CarrierType cType)
        {
            string key = "TextAlerts" + cType.ToString();

            return(language.GetString(key));
        }