Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AnimalId,Name,Description")] Animal animal)
        {
            if (id != animal.AnimalId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalExists(animal.AnimalId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(animal));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("PetFoodId,Price,Name,Description,NutritionalInformation,Weight,Brand,AnimalId")] PetFood petFood)
        {
            if (id != petFood.PetFoodId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(petFood);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetFoodExists(petFood.PetFoodId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AnimalId"] = new SelectList(_context.Animal, "AnimalId", "Name", petFood.AnimalId);
            return(View(petFood));
        }