示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("TutorId,Nome")] Tutor tutor)
        {
            if (id != tutor.TutorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tutor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TutorExists(tutor.TutorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tutor));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("PetId,Nome,Idade,Raca,Especie,TutorId")] Pet pet)
        {
            if (id != pet.PetId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pet);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetExists(pet.PetId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TutorId"] = new SelectList(_context.Tutores, "TutorId", "TutorId", pet.TutorId);
            return(View(pet));
        }