public async Task <IActionResult> Put(int pacienteId, Paciente model)
        {
            try
            {
                var paciente = await _pac.GetPacienteAsyncById(pacienteId);

                if (paciente == null)
                {
                    return(NotFound());
                }

                _pac.update(model);

                if (await _pac.SaveChangesAsync())
                {
                    return(Created($"/api/paciente/{model.Id}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Falha no Banco de dados"));
            }

            return(BadRequest());
        }
Example #2
0
        public async Task <IActionResult> Get(int medicoId)
        {
            try
            {
                var results = await _pac.GetPacienteAsyncById(medicoId);

                return(Ok(results));
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Falha no Banco de dados"));
            }
        }