Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,nome,prezzo,quantita")] Prodotto prodotto)
        {
            if (id != prodotto.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prodotto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdottoExists(prodotto.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(prodotto));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("repartoId,nome")] Reparto reparto)
        {
            if (id != reparto.repartoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reparto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!repartoExists(reparto.repartoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reparto));
        }