Exemplo n.º 1
0
        public ArticleDTO Find(int id)
        {
            try
            {
                var article = _newRepository.GetById(id);

                Mapper.Initialize(
                    cfg =>
                {
                    cfg.CreateMap <Article, ArticleDTO>();
                    cfg.CreateMap <User, UserDTO>();
                });
                var articleDto = Mapper.Map <Article, ArticleDTO>(article);
                _logger.Info("Get Article: id = " + id);
                return(articleDto);
            }
            catch (RepositoryException rep)
            {
                _logger.Error("Method: FindArticle ( long id )");
                _logger.Error(rep.Message);
                throw new ServiceException("Service exception: from repository ", rep);
            }
            catch (Exception ex)
            {
                _logger.Error("Method: FindArticle ( long id )", ex);
                throw new ServiceException("Method: FindArticle ( long id )", ex);
            }
        }
Exemplo n.º 2
0
 public News Get(int id)
 {
     return(_newRepository.GetById(id));
 }