コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,SellerId")] Item item)
        {
            if (id != item.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SellerId"] = new SelectList(_context.Sellers, "Id", "FirstName", item.SellerId);
            return(View(item));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email")] Buyer buyer)
        {
            if (id != buyer.Id)
            {
                return(NotFound());
            }

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