/// <summary>
 /// Create a new VendaProduto object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="id_Venda">Initial value of the id_Venda property.</param>
 /// <param name="id_Produto">Initial value of the id_Produto property.</param>
 /// <param name="qtd">Initial value of the qtd property.</param>
 public static VendaProduto CreateVendaProduto(global::System.Decimal id, global::System.Decimal id_Venda, global::System.Decimal id_Produto, global::System.Decimal qtd)
 {
     VendaProduto vendaProduto = new VendaProduto();
     vendaProduto.id = id;
     vendaProduto.id_Venda = id_Venda;
     vendaProduto.id_Produto = id_Produto;
     vendaProduto.qtd = qtd;
     return vendaProduto;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the VendaProdutoes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVendaProdutoes(VendaProduto vendaProduto)
 {
     base.AddObject("VendaProdutoes", vendaProduto);
 }
예제 #3
0
        public Venda ConverteMLVendaEmVenda(ML_Order o, NSAADM_HMLEntities e)
        {
            String id;
            id = o.id.ToString();

            ML_Shipping mS = o.ML_Shipping.FirstOrDefault();
            ML_FeedbackSeller Fb = o.ML_FeedbackSeller.FirstOrDefault();

            Venda v = new Venda();

            v.data_venda = Convert.ToDateTime(o.date_created);
            v.valor_venda = (decimal)o.total_amount;
            v.valor_desconto = 0;
            v.data_final = Convert.ToDateTime(o.date_closed);

            if (Fb != null)
            {
                v.status = ConvertStatus(o.status, Fb.rating);
            }
            else
            {
                v.status = ConvertStatus(o.status, "");
            }

            if (mS != null)
            {
                v.valor_frete = Convert.ToDecimal(mS.cost);
            }

            v.id_ML = id;

            Cliente c = (from p in e.Clientes where p.idML == id select p).FirstOrDefault();
            if (c == null)
            {
                c = new Cliente();
                c.email = o.ML_Usuario1.email;
                c.nome = o.ML_Usuario1.first_name;
                c.idML = o.id.ToString();
                c.nicknName = o.ML_Usuario1.nickname;
                c.ultimoNome = o.ML_Usuario1.last_name;
            }
            v.Cliente = c;

            ML_OrderItem mo = o.ML_OrderItem.FirstOrDefault();
            Produto pr = (from a in e.Produtoes where a.Descr == mo.ML_Item.title select a).FirstOrDefault();
            if (pr == null)
            {
                pr = new Produto();
                pr.Descr = mo.ML_Item.title;
                pr.qtd = (decimal)mo.quantity;
            }

            VendaProduto vp = new VendaProduto();
            vp.Produto = pr;
            vp.Venda = v;
            vp.qtd = (decimal)mo.quantity;

            v.VendaProdutoes.Add(vp);

            return v;
        }