Exemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("Id,Name,PetType")] Pet pet)
        {
            if (id != pet.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pet);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetExists(pet.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pet));
        }
        public IActionResult Edit(int id, [Bind("Id,CareTakerId,PetId,Start,End")] PetCareSession petCareSession)
        {
            if (id != petCareSession.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(petCareSession);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetCareSessionExists(petCareSession.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CareTakerId"] = new SelectList(_context.CareTaker, "Id", "Id", petCareSession.CareTakerId);
            ViewData["PetId"]       = new SelectList(_context.Pet, "Id", "Id", petCareSession.PetId);
            return(View(petCareSession));
        }
Exemplo n.º 3
0
        public IActionResult Edit(int id, [Bind("Id,Name,PhoneNumber")] CareTaker careTaker)
        {
            if (id != careTaker.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(careTaker);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CareTakerExists(careTaker.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(careTaker));
        }