예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Postcode")] Apiary apiary)
        {
            if (id != apiary.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(apiary);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApiaryExists(apiary.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(apiary));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Beehive beehive)
        {
            if (id != beehive.ID)
            {
                return(NotFound());
            }

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