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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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")); }
public void Edit(Pet pet) { db.Update(pet); db.SaveChanges(); }