private async Task <ArticleDto> GetByIdAsDto(int id) { var article = await _articlesRepository.GetById(id); var articleDto = FromModelToDto(article); return(articleDto); }
public IActionResult GetById(int id) { try { var entity = _articlesRepository.GetById(id); if (entity == null) { return(NotFound()); } return(Ok(entity)); } catch (DataException ex) { _logger.LogError(ex, "ArticlesController/GetById"); return(BadRequest()); } catch (Exception ex) { _logger.LogError(ex, "ArticlesController/GetById"); throw; } }