Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,DOB,Breed,OwnerId")] 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", "FullName", pet.OwnerId);
            return(View(pet));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Street,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));
        }