public IActionResult Edit(Agendamentos agendamento)
 {
     agendamento.Paciente = null;
     _context.Update(agendamento);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public IActionResult Edit(Paciente paciente)
        {
            ViewBag.error = null;
            try
            {
                if (_context.Pacientes.Where(e => e.Cpf == paciente.Cpf && e.Id != paciente.Id).Count() > 0)
                {
                    throw new Exception("Já existe um paciente com esse CPF cadastrado.");
                }

                if (_context.Pacientes.Where(e => e.Email == paciente.Email && e.Id != paciente.Id).Count() > 0)
                {
                    throw new Exception("Já existe um paciente com esse E-mail cadastrado.");
                }
                _context.Update(paciente);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.error    = e.Message;
                ViewBag.Convenio = new SelectList(_context.Convenios, "Id", "Nome");
                return(View(paciente));
            }
        }
Example #3
0
 public IActionResult Edit(Convenio convenio)
 {
     ViewBag.error = null;
     try
     {
         if (_context.Convenios.Where(e => e.Nome == convenio.Nome && e.Id != convenio.Id).Count() > 0)
         {
             throw new Exception("Já existe um Convênio criado com esse nome.");
         }
         _context.Update(convenio);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ViewBag.error = e.Message;
         return(View(convenio));
     }
 }
Example #4
0
 public IActionResult Edit(Clinica clinica)
 {
     ViewBag.error = null;
     try
     {
         if (_context.Clinicas.Where(e => e.Cnpj == clinica.Cnpj && e.Id != clinica.Id).Count() > 0)
         {
             throw new Exception("Já existe uma clínica criada com esse CNPJ");
         }
         _context.Update(clinica);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ViewBag.error = e.Message;
         return(View(clinica));
     }
 }