Beispiel #1
0
        public async Task <IActionResult> Create([Bind("OwnerId,FirstName,LastName,email,Photo,PhoneNumber")] Owner owner)
        {
            if (ModelState.IsValid)
            {
                _context.Add(owner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(owner));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("PetId,Name,OwnerId,Age,Picture")] Pet pet)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pet);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnerId"] = new SelectList(_context.Owner, "OwnerId", "OwnerId", pet.OwnerId);
            return(View(pet));
        }