Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ConsultaID,MedicoID,PacienteID,DataConsulta,DataFinalConsulta")] Consulta consulta)
        {
            if (id != consulta.ConsultaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consulta);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsultaExists(consulta.ConsultaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MedicoID"]   = new SelectList(_context.Medicos, "MedicoID", "Nome", consulta.MedicoID);
            ViewData["PacienteID"] = new SelectList(_context.Pacientes, "PacienteID", "NomePaciente", consulta.PacienteID);
            return(View(consulta));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("PacienteID,NomePaciente,Cpf,NumTelefone,Email,Rua,Numero,Bairro,Cidade")] Paciente paciente)
        {
            if (id != paciente.PacienteID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paciente);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PacienteExists(paciente.PacienteID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        //Log the error (uncomment ex variable name and write a log.)
                        ModelState.AddModelError("", "Unable to save changes. " +
                                                 "Try again, and if the problem persists, " +
                                                 "see your system administrator.");
                    }
                }
            }
            return(View(paciente));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("MedicoID,Nome,Email,Especialidade")] Medico medico)
        {
            if (id != medico.MedicoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medico);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicoExists(medico.MedicoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medico));
        }