예제 #1
0
        /// <summary>
        /// Add a pickup count object to the PickupSummary IEnumerable
        /// </summary>
        /// <typeparam name="C">IPickupCountType</typeparam>
        /// <typeparam name="W">IParcelWeight</typeparam>
        /// <param name="s">Service</param>
        /// <param name="c">Count</param>
        /// <param name="w">Total weight</param>
        /// <param name="u">Unit of weight</param>
        /// <returns></returns>
        public PickupFluent <T> AddPickupSummary <C, W>(PickupService s, int c, decimal w, UnitOfWeight u) where C : IPickupCount, new() where W : IParcelWeight, new()
        {
            var ct = new C
            {
                ServiceId   = s,
                TotalWeight = new W {
                    UnitOfMeasurement = u, Weight = w
                },
                Count = c
            };

            _pickup.AddPickupCount(ct);
            return(this);
        }
예제 #2
0
        private void AddPickUpService()
        {
            var pickupEventRepository         = ServiceProvider.GetService <PickupEventRepository>();
            var movementEventRepository       = ServiceProvider.GetService <MovementEventRepository>();
            var addToInventoryEventRepository = ServiceProvider.GetService <AddToInventoryEventRepository>();

            var player = GameObject;

            var config = ServiceProvider.GetService <PlayerConfig>();

            var service = new PickupService(pickupEventRepository, movementEventRepository,
                                            addToInventoryEventRepository, player.transform, config);

            Services.Add(service);
        }
예제 #3
0
        private async void BookNewOrder()
        {
            try
            {
                var streetaddress       = txtAdress.Text;
                var postalcode          = txtPostalCode.Text;
                int convertedpostalcode = int.Parse(postalcode);
                var city = txtCity.Text;

                string[] subs = streetaddress.Split(' ');

                foreach (var sub in subs)
                {
                    Console.WriteLine($"Substring: {sub}");
                }


                string streetname   = subs[0];
                string streetNumber = subs[1];


                var additionalServiceCodeStandard = new List <string>
                {
                    "A1"
                };
                var itemList = new List <long>
                {
                    373500489530470000
                };



                List <PickupService> newist = new List <PickupService>();

                newist.Add(new PickupService()
                {
                    typeOfItem = "parcel", noUnits = 1
                });



                Service Servicebody = new Service
                {
                    basicServiceCode      = "19",
                    additionalServiceCode = new List <string>
                    {
                        "A1"
                    }
                };



                Service2 service2 = new Service2
                {
                    service = Servicebody
                };

                Shipment2 shipment2 = new Shipment2
                {
                    shipment = service2
                };

                var Shipmentbody = new Shipment
                {
                    items = itemList
                };
                var LocationBody = new Location
                {
                    place        = "Company name or information about pickup place e.g.garage",
                    streetName   = streetname,
                    streetNumber = streetNumber,
                    postalCode   = convertedpostalcode,
                    city         = city,
                    countryCode  = "SE"
                };

                Location2 location2 = new Location2
                {
                    location = LocationBody
                };

                var OrderBody = new Order
                {
                    customerNumber = "1234567891",
                    orderReference = "Ref-1212122A",
                    contactName    = "Nils Andersson",
                    contactEmail   = "*****@*****.**",
                    phoneNumber    = "+4670788888",
                    smsNumber      = "+4670788888",
                    entryCode      = "8216"
                };

                var Order2 = new Order2
                {
                    order = OrderBody
                };

                var PickUpBody = new PickupService
                {
                    typeOfItem = "parcel",
                    noUnits    = 1
                };

                var PickUp2 = new PickUp2
                {
                    pickups = newist
                };


                var datesandtimesBody = new DateAndTimes
                {
                    readyPickupDate    = new DateTime(2021, 5, 13),
                    latestPickupDate   = new DateTime(2021, 5, 13),
                    earliestPickupDate = new DateTime(2021, 5, 13)
                };

                var datesandtimes2 = new DateAndTimes2
                {
                    DateAndTimes = datesandtimesBody
                };



                var client = new RestClient("https://api2.postnord.com/rest/order/v1/pickup/SE?apikey=0ba91457361a67d1495aefa8519ba3cb");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                // request.AddParameter("text/plain", "{\r\n  \"shipment\": {\r\n    \"service\": {\r\n      \"basicServiceCode\": \"19\",\r\n      \"additionalServiceCode\": [\r\n        \"A1\"\r\n      ]\r\n    },\r\n    \"items\": [\r\n      373500489530470000\r\n    ]\r\n  },\r\n  \"location\": {\r\n    \"place\": \"Company name or information about pickup place e.g. garage\",\r\n    \"streetName\": \"streetname\",\r\n    \"streetNumber\": \"streetNumber\",\r\n    \"postalCode\": postalcode,\r\n    \"city\": \"txtCity\",\r\n    \"countryCode\": \"SE\"\r\n  },\r\n  \"order\": {\r\n    \"customerNumber\": \"1234567891\",\r\n    \"orderReference\": \"Ref-1212122A\",\r\n    \"contactName\": \"Nils Andersson\",\r\n    \"contactEmail\": \"[email protected]\",\r\n    \"phoneNumber\": \"+4670788888\",\r\n    \"smsNumber\": \"+4670788888\",\r\n    \"entryCode\": \"8216\"\r\n  },\r\n  \"pickup\": [\r\n    {\r\n      \"typeOfItem\": \"parcel\",\r\n      \"noUnits\": 1\r\n    }\r\n  ],\r\n  \"dateAndTimes\": {\r\n    \"readyPickupDate\": \"2020-11-17T09:52:07.929Z\",\r\n    \"latestPickupDate\": \"2020-11-17T09:52:07.929Z\",\r\n    \"earliestPickupDate\": \"2020-11-17T09:52:07.929Z\"\r\n  }\r\n}", ParameterType.RequestBody);


                request.AddHeader("Accept", "application/json");
                request.Parameters.Clear();



                string json  = JsonConvert.SerializeObject(shipment2, Formatting.Indented);
                string json2 = JsonConvert.SerializeObject(Shipmentbody, Formatting.Indented);
                string json3 = JsonConvert.SerializeObject(location2, Formatting.Indented);
                string json4 = JsonConvert.SerializeObject(Order2, Formatting.Indented);
                string json5 = JsonConvert.SerializeObject(PickUp2, Formatting.Indented);
                string json6 = JsonConvert.SerializeObject(datesandtimes2, Formatting.Indented);

                await DisplayAlert("Alert", json + json2 + json3 + json4 + json5 + json6, "OK");

                Console.WriteLine(json + json2 + json3 + json4 + json5 + json6);

                request.RequestFormat = DataFormat.Json;

                request.AddJsonBody(shipment2);
                request.AddJsonBody(Shipmentbody);
                request.AddJsonBody(location2);
                request.AddJsonBody(Order2);
                request.AddJsonBody(PickUp2);
                request.AddJsonBody(datesandtimes2);

                IRestResponse response = client.Execute(request);
                await DisplayAlert("Alert", response.Content.ToString(), "OK");
            }
            catch (Exception ex)

            {
                Console.WriteLine(ex);
                await DisplayAlert("Alert!", "Incorrect adress, try again", "OK");
            }
        }