[ValidateAntiForgeryToken] //Prevenimos cambios externos public async Task <IActionResult> Create([Bind("PubIntIdPaciente,PubStrNombre,PubStrSeguro,PubStrCodigoPostal,PubStrTelefono,PubStrDireccion,PubStrEmail")] Paciente paciente) { if (ModelState.IsValid) { _context.Add(paciente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(paciente)); }
[HttpPost] //Metodo editar encargado del proceso POST al formulario BD public async Task <IActionResult> Edit(int id, [Bind("PubIntIdEspecialidad,PubStrDescripcion")] Especialidad especialidad) { if (id != especialidad.PubIntIdEspecialidad) { return(NotFound()); } if (ModelState.IsValid) { _context.Update(especialidad); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(especialidad)); }
[ValidateAntiForgeryToken] //Prevenimos cambios externos public async Task <IActionResult> Create([Bind("PubIntIdDoctor,PubStrNombre,PubStrCredencial,PubStrHospital,PubStrTelefono,PubStrEmail")] Doctor doctor, int PubIntIdEspecialidad) { if (ModelState.IsValid) { _context.Add(doctor); await _context.SaveChangesAsync(); var doctorEspecialidad = new DoctorEspecialidad(); doctorEspecialidad.PubIntIdDoctor = doctor.PubIntIdDoctor; doctorEspecialidad.PubIntIdEspecialidad = PubIntIdEspecialidad; _context.Add(doctorEspecialidad); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(doctor)); }