示例#1
0
        public async Task <IActionResult> Create(VentasLineas VentasLineas)
        {
            if (ModelState.IsValid)
            {
                _context.Add(VentasLineas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(VentasLineas));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, VentasLineas VentasLineas)
        {
            if (id != VentasLineas.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid || 1 == 1)
            {
                try
                {
                    _context.Update(VentasLineas);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VentasLineasExists(VentasLineas.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.Producto = new SelectList(_context.Productos.Select(x => new Productos()
            {
                id = x.id, tipo = x.tipo + "-" + x.id
            }).Distinct(), "id", "tipo");
            ViewBag.Servicio = new SelectList(_context.Servicios.Select(x => new Servicios()
            {
                id = x.id, tipo = x.tipo + "-" + x.id
            }).Distinct(), "id", "tipo");

            return(View(VentasLineas));
        }