Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("DetallesDeVentaID,VentaID,ProductoID,Descripcion,price,Quantity,discountamount")] DetallesDeVenta detallesDeVenta)
        {
            if (id != detallesDeVenta.DetallesDeVentaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(detallesDeVenta);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DetallesDeVentaExists(detallesDeVenta.DetallesDeVentaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductoID"] = new SelectList(_context.Set <Producto>(), "ProductoID", "ArticleCode", detallesDeVenta.ProductoID);
            ViewData["VentaID"]    = new SelectList(_context.Set <Venta>(), "VentaID", "VentaID", detallesDeVenta.VentaID);
            return(View(detallesDeVenta));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("DetallesDeVentaID,VentaID,ProductoID,Descripcion,price,Quantity,discountamount")] DetallesDeVenta detallesDeVenta)
        {
            if (ModelState.IsValid)
            {
                _context.Add(detallesDeVenta);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductoID"] = new SelectList(_context.Set <Producto>(), "ProductoID", "ArticleCode", detallesDeVenta.ProductoID);
            ViewData["VentaID"]    = new SelectList(_context.Set <Venta>(), "VentaID", "VentaID", detallesDeVenta.VentaID);
            return(View(detallesDeVenta));
        }