Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PetName, PetType, PetSize, PetDOB, PetGender, HasPic, ImgType, SpeciesID, OwnerID")] Pet pet)
        {
            if (id != pet.PetID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pet);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetExists(pet.PetID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnerID"] = new SelectList(_context.Owners, "OwnerID", "OwnerAddress", pet.OwnerID);
            ViewData["PetID"]   = new SelectList(_context.Species, "SpeciesID", "SpeciesGender", pet.PetID);
            return(View(pet));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("SpeciesName,SpeciesType,SpeciesGender,PetID,OwnerID")] Species species)
        {
            if (id != species.SpeciesID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(species);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpeciesExists(species.SpeciesID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnerID"] = new SelectList(_context.Owners, "OwnerID", "OwnerAddress", species.OwnerID);
            return(View(species));
        }