コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Descripcion,Telefono,Direccion,Email")] Cliente cliente)
        {
            if (id != cliente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Descripcion,Categoriaid,Cantidad,Precio,Costo,Impuestoventas,Impuestovarios")] Producto producto)
        {
            if (id != producto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductoExists(producto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["Categoriaid"] = new SelectList(_context.Categoriaproducto, "Id", "Categoria", producto.Categoriaid);
            return(View(producto));
        }