Exemplo n.º 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));
        }
Exemplo n.º 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.Owners, "OwnerId", "OwnerId", pet.OwnerId);
            return(View(pet));
        }