public JsonResult AgregarMenuAVenta(DetalleDeVenta detalle) { detalle.Elaboracion = null; var result = _ventasService.AgregarDetalleAVenta(detalle, User.Identity.GetUserId()); if (result) { _db.SaveChanges(); return(Json(new { Result = true, DetalleId = detalle.Id }, JsonRequestBehavior.AllowGet)); } return(Json(new { Result = false, DetalleId = 0 }, JsonRequestBehavior.AllowGet)); }
protected void btnConfirmarCompra_Click(object sender, EventArgs e) { Pedido pedido = new Pedido(); DetalleDeVenta detalle = new DetalleDeVenta(); Negocio neg = new Negocio(); Random rnd = new Random(); int usuario = (int)Session["Cliente"]; string forma = "Efectivo"; DataTable td = (DataTable)Session["Carrito"]; pedido.Datos = neg.DatosUsuario(usuario); //pedido.NumeroFactura =rnd.Next(); pedido.NumeroFactura = 1234; pedido.Fecha = DateTime.Now; foreach (DataRow row in td.Rows) { pedido.Total += Convert.ToDecimal(row["Precio Final"].ToString()); } if (var == 2) { forma = "Debito"; } else if (var == 3) { forma = "Credito"; } else if (var == 4) { forma = "Mercadopago"; } pedido.Pago = neg.DatoTarjeta(forma); neg.Guardarventa(pedido.Datos, pedido.NumeroFactura, pedido.Fecha, pedido.Total, pedido.Pago); detalle.Pedido = neg.DatoPedido(pedido.NumeroFactura); foreach (DataRow row in td.Rows) { detalle.Articulos = Convert.ToInt32(row["Id"].ToString()); detalle.Cantidad = Convert.ToInt32(row["Cantidad"].ToString()); detalle.Precio = Convert.ToDecimal(row["Precio Unit"].ToString()); neg.GuardarDetallesVentas(detalle.Pedido, detalle.Articulos, detalle.Cantidad, detalle.Precio); } }