Esempio n. 1
0
        public List <Shipping> GetShipping(string cep)
        {
            string origem      = "04094-050";
            string destino     = cep;
            double peso        = 0;
            int    largura     = 0;
            int    altura      = 0;
            int    comprimento = 0;

            Shipping freteFacil = new Shipping
            {
                Id   = "frete-facil",
                Name = "PayPal Frete Fácil"
            };

            Shipping freteECT = new Shipping
            {
                Id   = "sedex",
                Name = "SEDEX Correios"
            };

            foreach (Item item in items)
            {
                if (item.Product.Length > comprimento)
                {
                    comprimento = item.Product.Length;
                }

                if (item.Product.Width > largura)
                {
                    largura = item.Product.Width;
                }

                altura += item.Product.Height;
                peso   += item.Product.Weight;
            }

            FreteFacilApi wsFreteFacil = PayPalApiFactory.instance.FreteFacil();

            freteFacil.Value = wsFreteFacil.getPreco(
                origem,
                destino,
                largura,
                altura,
                comprimento,
                peso.ToString()
                );

            CalcPrecoPrazoWS wsECT = new CalcPrecoPrazoWS();

            freteECT.Value = Double.Parse(wsECT.CalcPrecoPrazo(
                                              "", "", "40010",
                                              origem,
                                              destino,
                                              peso.ToString(),
                                              1,
                                              comprimento,
                                              altura,
                                              largura,
                                              0, "n", 0, "n"
                                              ).Servicos[0].Valor);

            return(new List <Shipping> {
                freteFacil,
                freteECT
            });
        }
        public List<Shipping> GetShipping(string cep)
        {
            string origem = "04094-050";
            string destino = cep;
            double peso = 0;
            int largura = 0;
            int altura = 0;
            int comprimento = 0;

            Shipping freteFacil = new Shipping
            {
                Id = "frete-facil",
                Name = "PayPal Frete Fácil"
            };

            Shipping freteECT = new Shipping
            {
                Id = "sedex",
                Name = "SEDEX Correios"
            };

            foreach (Item item in items)
            {
                if (item.Product.Length > comprimento)
                {
                    comprimento = item.Product.Length;
                }

                if (item.Product.Width > largura)
                {
                    largura = item.Product.Width;
                }

                altura += item.Product.Height;
                peso += item.Product.Weight;
            }

            FreteFacilApi wsFreteFacil = PayPalApiFactory.instance.FreteFacil();
            freteFacil.Value = wsFreteFacil.getPreco(
            origem,
            destino,
            largura,
            altura,
            comprimento,
            peso.ToString()
            );

            CalcPrecoPrazoWS wsECT = new CalcPrecoPrazoWS();
            freteECT.Value = Double.Parse(wsECT.CalcPrecoPrazo(
            "", "", "40010",
            origem,
            destino,
            peso.ToString(),
            1,
            comprimento,
            altura,
            largura,
            0, "n", 0, "n"
            ).Servicos[0].Valor);

            return new List<Shipping> {
freteFacil,
freteECT
};
        }