Exemple #1
0
        public async Task <IActionResult> GetAuthor(int id)
        {
            var location = GetControllerActionNames();

            try
            {
                _logger.LogInfo($"{location}: Attempted Call for id: {id}");
                var profession = await _professionRepository.FindById(id);

                if (profession == null)
                {
                    _logger.LogWarn($"{location}: Failed to retrieve record with id: {id}");
                    return(NotFound());
                }
                var response = _mapper.Map <ProfessionDTO>(profession);
                _logger.LogInfo($"{location}: Successfully got record with id: {id}");
                return(Ok(response));
            }
            catch (Exception e)
            {
                return(InternalError($"{location}: {e.Message} - {e.InnerException}"));
            }
        }