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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(estado);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EstadoExists(estado.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(estado));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Type")] Pet pet)
        {
            if (id != pet.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pet);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetExists(pet.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pet));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Endereco,DataNascimento,DataDeCadastro,Sexo")] Dados dados)
        {
            if (id != dados.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dados);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DadosExists(dados.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dados));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Cep,Logradouro,Numero,Complemento,DonoId")] Endereco endereco)
        {
            if (id != endereco.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(endereco);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnderecoExists(endereco.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(endereco));
        }
示例#5
0
        public async Task <IActionResult> Edit(int id, [Bind("Raca,LocalizacaoId,Id,Nome,Endereco,DataNascimento,DataDeCadastro,Sexo")] Animal animal)
        {
            if (id != animal.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalExists(animal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(animal));
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Longitude,Latitude")] Localizacao localizacao)
        {
            if (id != localizacao.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(localizacao);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocalizacaoExists(localizacao.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(localizacao));
        }
示例#7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NumeroDeSerie,LocalizacaoId")] Rastreador rastreador)
        {
            if (id != rastreador.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rastreador);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RastreadorExists(rastreador.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(rastreador));
        }
示例#8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,EnderecoId")] Cidade cidade)
        {
            if (id != cidade.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cidade);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CidadeExists(cidade.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cidade));
        }
示例#9
0
        public IActionResult UpdateAnimal(Animal animal, int animalId)
        {
            ModelState.Remove("PictureName"); //For not checking the PictureName required property of animal model
            ModelState.Remove("AnimalImage"); //For not checking the AnimalImage required property of animal model

            if (ModelState.IsValid)
            {
                var updatedAnimal = _context.Animals.SingleOrDefault(a => a.AnimalId == animalId);

                updatedAnimal.Name        = animal.Name;
                updatedAnimal.Age         = animal.Age;
                updatedAnimal.CategoryId  = animal.CategoryId;
                updatedAnimal.Description = animal.Description;

                _context.Update(updatedAnimal);
                _context.SaveChanges();

                return(RedirectToAction("Index", new { isSucceed = true }));
            }

            return(RedirectToAction("EditAnimal"));
        }
示例#10
0
 public void Edit(Pet pet)
 {
     db.Update(pet);
     db.SaveChanges();
 }