Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] Animal animal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(animal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(animal));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Price,Name,Description,NutritionalInfo,Weight,Brand,AnimalId")] PetFood petFood)
        {
            if (ModelState.IsValid)
            {
                _context.Add(petFood);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AnimalId"] = new SelectList(_context.Animal, "Id", "Name", petFood.AnimalId);
            return(View(petFood));
        }