public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,CidadeId")] CidadeModel cidadeModel)
        {
            if (id != cidadeModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    cidadeModel.Nome = cidadeModel.Nome.ToUpper();
                    _context.Update(cidadeModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CidadeModelExists(cidadeModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CidadeId"] = new SelectList(_context.EstadoModel, "Id", "Nome", cidadeModel.CidadeId);
            return(View(cidadeModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,ProprietarioId,EspecieId,Peso,Altura,Comprimento,Pedigree")] AnimalModel animalModel)
        {
            if (id != animalModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    animalModel.Nome = animalModel.Nome.ToUpper();
                    _context.Update(animalModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalModelExists(animalModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EspecieId"]      = new SelectList(_context.EspecieModel, "Id", "Nome", animalModel.EspecieId);
            ViewData["ProprietarioId"] = new SelectList(_context.ProprietarioModel, "Id", "Nome", animalModel.ProprietarioId);
            return(View(animalModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] EspecieModel especieModel)
        {
            if (id != especieModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    especieModel.Nome = especieModel.Nome.ToUpper();
                    _context.Update(especieModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EspecieModelExists(especieModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(especieModel));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,HospitalId,Nome,CRV")] VeterinarioModel veterinarioModel)
        {
            if (id != veterinarioModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    veterinarioModel.Nome = veterinarioModel.Nome.ToUpper();
                    _context.Update(veterinarioModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VeterinarioModelExists(veterinarioModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HospitalId"] = new SelectList(_context.HospitalModel, "Id", "Nome", veterinarioModel.HospitalId);
            return(View(veterinarioModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,AnimalId,DataDaConsulta,HorarioDaConsulta")] ConsultaModel consultaModel)
        {
            if (id != consultaModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consultaModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsultaModelExists(consultaModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AnimalId"] = new SelectList(_context.AnimalModel, "Id", "Nome", consultaModel.AnimalId);
            return(View(consultaModel));
        }