コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,LastName,FirstName,EnrollmentDate,City,EmailAddress,PhoneNumber,Occupation")] Owner owner)
        {
            if (id != owner.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(owner);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OwnerExists(owner.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(owner));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,DOB,OwnerID,Breed")] Pet pet)
        {
            if (id != pet.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pet);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetExists(pet.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnerID"] = new SelectList(_context.Owner, "ID", "ID", pet.OwnerID);
            return(View(pet));
        }