Exemplo n.º 1
0
        public void calcular_peso_total()
        {
            var result   = WeightUtilitties.calculateTotalWeight(4.3f, 5.1f);
            int expected = 6;

            Assert.AreEqual(result, expected);
        }
Exemplo n.º 2
0
        public void calcular_sobre_peso()
        {
            var result   = WeightUtilitties.calculateSobrePeso(1, "2.5");
            var expected = 2;

            Assert.AreEqual(expected, 2);
        }
Exemplo n.º 3
0
        public async Task <JsonResult> IndexAsync()
        {
            Reporte        reportItem;
            List <Reporte> listaReport = new List <Reporte>();
            //Recuperamos información de guías desde un archivo en formato JSON
            var itemsInJsonFile = JsonUtilities.readJsonFile("Data\\labels.json");

            //Cálculo de peso volumétrico de cáda item que se encuentra en el Json, este cálculo se guarda un la propiedad del objeto llamada volumetricWeight
            foreach (var shipment in itemsInJsonFile)
            {
                shipment.volumetricWeight = WeightUtilitties.calculateVolumetricWeight(shipment.parcel.width, shipment.parcel.height, shipment.parcel.length);
                //Decidimos el peso total del item y lo metemos en el reporte
                reportItem = new Reporte {
                    ticketWeight = WeightUtilitties.calculateTotalWeight(shipment.volumetricWeight, shipment.parcel.weight)
                };
                //Llamada al servicio asyncrona
                Task <string> soapRequest = CreateSoapEnvelopeAsync(
                    _configuration.GetValue <string>("Key"),
                    _configuration.GetValue <string>("Password"),
                    _configuration.GetValue <string>("AccountNumber"),
                    _configuration.GetValue <string>("MeterNumber"),
                    shipment.tracking_number
                    );
                //Recuperamos informacion del peso real del servicio
                reportItem.realWeight = await soapRequest;
                //Calculamos si existe el sobre peso
                reportItem.sobrePeso = WeightUtilitties.calculateSobrePeso(reportItem.ticketWeight, reportItem.realWeight);
                if (reportItem.sobrePeso > 0)
                {
                    reportItem.hasSobrePeso = true;
                }
                listaReport.Add(reportItem);
            }

            return(Json(new { listaReport }));
        }