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

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

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