public async Task <ActionResult <PatientViewModel> > GetPatientById(Guid id)
        {
            _logger.LogInformation($"Get patient by id {id.ToString()}");
            if (id == Guid.Empty)
            {
                return(NotFound("No such patient exists"));
            }
            try
            {
                var model = await _patientManager.GetPatientByIdAsync(id);

                if (model == null)
                {
                    return(NotFound("No such patient exists"));
                }
                var result = _mapper.Map <PatientViewModel>(model);

                return(Ok(result));
            }
            catch (Exception e)
            {
                throw new HttpStatusCodeException(500,
                                                  "Error happend when get patient by Id." + e.Message);
            }
        }
Ejemplo n.º 2
0
        public async Task <JsonResult <PatientForViewDto> > GetPatientByIdAsync([FromRoute] int id)
        {
            JsonResult <PatientForViewDto> result = await ExecuteActionWithResultAsync(async() =>
                                                                                       await _patientManager.GetPatientByIdAsync(id)) as JsonResult <PatientForViewDto>;

            return(result);
        }