예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Ad,Tur,Fiyat,YazarID")] Kitap kitap)
        {
            if (id != kitap.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(kitap);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KitapExists(kitap.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["YazarID"] = new SelectList(_context.Yazarlar, "ID", "ID", kitap.YazarID);
            return(View(kitap));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Ad")] Yazar yazar)
        {
            if (id != yazar.ID)
            {
                return(NotFound());
            }

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