コード例 #1
0
        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));
        }
コード例 #2
0
        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"));
        }