コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,JeloId,Količina")] Košarica košarica)
        {
            if (id != košarica.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(košarica);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KošaricaExists(košarica.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["JeloId"] = new SelectList(_context.Jelo, "Id", "Naziv", košarica.JeloId);
            return(View(košarica));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Naziv,Cijena")] Jelo jelo)
        {
            if (id != jelo.Id)
            {
                return(NotFound());
            }

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