public async Task <IActionResult> Atualizar(AtualizarMedicoViewModel medicoViewModel) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } var especialidades = MontaEspecialidades(medicoViewModel.Especialidades); var medico = new Medico(medicoViewModel.Id, medicoViewModel.Nome, medicoViewModel.Cpf, medicoViewModel.Crm, especialidades); await _medicoService.Atualizar(medico); if (!OperacaoValida()) { return(CustomResponse()); } var viewModel = MontaMedicoViewModel(medico); return(Ok(viewModel)); }
public async Task <IActionResult> Edit(Guid id, MedicoViewModel medicoViewModel) { if (id != medicoViewModel.Id) { return(NotFound()); } if (!ModelState.IsValid) { return(View(medicoViewModel)); } var medico = _mapper.Map <Medico>(medicoViewModel); await _medicoService.Atualizar(medico); if (!OperacaoValida()) { return(View(medicoViewModel)); } return(RedirectToAction("Index")); }