Exemple #1
0
        public IActionResult NewVenta(VentasViewModel model)
        {
            if (ModelState.IsValid)
            {
                var venta = _context.Venta.Add(model.VentaCabecera);
                _context.SaveChanges();

                foreach (var item in ventaDetalles)
                {
                    item.IdVenta = venta.Entity.Id;
                    _context.VentaDetalle.Add(item);
                    _context.SaveChanges();
                }

                return(RedirectToAction("Index", "Ventas"));
            }


            return(View());
        }
        public IActionResult NewVenta(VentasViewModel model)
        {
            if (ModelState.IsValid)
            {
                _context.Venta.Add(model.VentaCabecera);
                _context.SaveChanges();
            }


            return(View());
        }