Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Behavior")] AnimalBreed animalBreed)
        {
            if (id != animalBreed.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animalBreed);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalBreedExists(animalBreed.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(animalBreed));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Behavior")] AnimalBreed animalBreed)
        {
            if (ModelState.IsValid)
            {
                _context.Add(animalBreed);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(animalBreed));
        }