public async Task<ActionResult> View(string serie, string tipoDoc, string numDoc)
        {
            System.Diagnostics.Debug.WriteLine(serie + " " + tipoDoc + " " + numDoc);
            var client = new HttpClient();
            var response = await client.GetAsync("http://localhost:49990/api/Vendas/Documento?" + "serie=" + serie + "&tipoDoc=" + tipoDoc + "&numDoc=" +numDoc);

            var linhaDoc = await response.Content.ReadAsAsync<IEnumerable<LinhaDocumento>>();

            response = await client.GetAsync("http://localhost:49990/api/Vendas");
            var vendas = await response.Content.ReadAsAsync<IEnumerable<Venda>>();

            var venda = new Venda();
            foreach(var v in vendas)
            {
                if(v.NumDoc == Int32.Parse(numDoc) && v.Serie == serie && v.TipoDoc == tipoDoc)
                {
                    venda = v;
                }
            }
            ViewBag.linhaDoc = linhaDoc;
            ViewBag.venda = venda;
            return View(linhaDoc);
        }
        public static Venda GetVenda(string id)
        {
            StdBELista objList;

            Venda venda = new Venda();

            if (PriEngine.InitializeCompany(SINF_EXAMPLE_WS.Properties.Settings.Default.Company.Trim(), SINF_EXAMPLE_WS.Properties.Settings.Default.User.Trim(), SINF_EXAMPLE_WS.Properties.Settings.Default.Password.Trim()) == true)
            {

                objList = PriEngine.Engine.Consulta("SELECT \"CabecDoc\".\"TipoDoc\", \"CabecDoc\".\"Entidade\", \"CabecDoc\".\"NumDoc\", \"CabecDoc\".\"TotalIva\", \"CabecDoc\".\"TotalDesc\", \"CabecDoc\".\"TotalOutros\", \"CabecDoc\".\"Data\", \"DocumentosVenda\".\"Descricao\", \"CabecDoc\".\"TotalMerc\", \"CabecDoc\".\"Serie\", \"CabecDoc\".\"Nome\", \"CabecDoc\".\"Cambio\", \"CabecDoc\".\"CambioMBase\", \"CabecDoc\".\"CambioMAlt\", \"CabecDoc\".\"TotalEcotaxa\", \"CabecDoc\".\"TotalIEC\", \"EstadosConta\".\"Adiantamento\", \"CabecDoc\".\"TipoEntidade\", \"CabecDocStatus\".\"Anulado\" FROM   ((\"CabecDoc\" \"CabecDoc\" INNER JOIN \"DocumentosVenda\" \"DocumentosVenda\" ON \"CabecDoc\".\"TipoDoc\"=\"DocumentosVenda\".\"Documento\") INNER JOIN \"CabecDocStatus\" \"CabecDocStatus\" ON \"CabecDoc\".\"Id\"=\"CabecDocStatus\".\"IdCabecDoc\") LEFT OUTER JOIN \"EstadosConta\" \"EstadosConta\" ON (\"DocumentosVenda\".\"TipoConta\"=\"EstadosConta\".\"TipoConta\") AND (\"DocumentosVenda\".\"Estado\"=\"EstadosConta\".\"Estado\") WHERE (\"CabecDoc\".\"NumDoc\" = '" + id + "') AND (\"CabecDoc\".\"TipoDoc\"=N'AVE' OR \"CabecDoc\".\"TipoDoc\"=N'FA' OR \"CabecDoc\".\"TipoDoc\"=N'GR' OR \"CabecDoc\".\"TipoDoc\"=N'NC' OR \"CabecDoc\".\"TipoDoc\"=N'VD') AND (\"CabecDoc\".\"Data\">= '2014-01-01 00:00:00' AND \"CabecDoc\".\"Data\"< '2015-10-20 00:00:00') AND \"CabecDocStatus\".\"Anulado\"=0 AND (\"CabecDoc\".\"Serie\"=N'A' OR \"CabecDoc\".\"Serie\"=N'C') ORDER BY \"CabecDoc\".\"TipoDoc\", \"CabecDoc\".\"NumDoc\"");

                if (!objList.Vazia())
                {
                    venda.TipoDoc = objList.Valor("TipoDoc");
                    venda.Entidade = objList.Valor("Entidade");
                    venda.NumDoc = objList.Valor("NumDoc");
                    venda.TotalIva = objList.Valor("TotalIva");
                    venda.TotalDesc = objList.Valor("TotalDesc");
                    venda.TotalOutros = objList.Valor("TotalOutros");
                    venda.Data = objList.Valor("Data");
                    venda.Descricao = objList.Valor("Descricao");
                    venda.TotalMerc = objList.Valor("TotalMerc");
                    venda.Serie = objList.Valor("Serie");
                    venda.Nome = objList.Valor("Nome");
                    venda.TotalEcotaxa = objList.Valor("TotalEcotaxa");
                    venda.TotalIEC = objList.Valor("TotalIEC");
                    //Adiantamento = objList.Valor("Adiantamento"),
                    venda.TipoEntidade = objList.Valor("TipoEntidade");
                    venda.Anulado = objList.Valor("Anulado");

                    return venda;
                }

            }

            return null;
        }