Ejemplo n.º 1
0
 public void IncluirVenda(Venda v, NSAADM_HMLEntities e)
 {
     e.Vendas.AddObject(v);
     e.SaveChanges();
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Vendas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVendas(Venda venda)
 {
     base.AddObject("Vendas", venda);
 }
 /// <summary>
 /// Create a new Venda object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="data_venda">Initial value of the data_venda property.</param>
 /// <param name="valor_venda">Initial value of the valor_venda property.</param>
 public static Venda CreateVenda(global::System.Decimal id, global::System.DateTime data_venda, global::System.Decimal valor_venda)
 {
     Venda venda = new Venda();
     venda.id = id;
     venda.data_venda = data_venda;
     venda.valor_venda = valor_venda;
     return venda;
 }
Ejemplo n.º 4
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;
        }