public void Update(ArticleDTO articleDto) { try { var user = _newRepository.GetAll().FirstOrDefault(p => p.Id == articleDto.Id && p.UserId == articleDto.UserId); if (user == null) { throw new ServiceException("You don`t have permissions to make this action!"); } _logger.Info("Start update in article with id " + articleDto.Id); var article = _newRepository.GetById(articleDto.Id); if (article == null) { throw new ServiceException("No article with this id"); } Mapper.Initialize( cfg => cfg.CreateMap <ArticleDTO, Article>()); article.Id = articleDto.Id; article.Text = articleDto.Text; article.ImageUrl = articleDto.ImageUrl; article.Header = articleDto.Header; article.ShortDescription = articleDto.ShortDescription; article.PublishDate = DateTime.Now; _newRepository.Update(article); _logger.Info("Update article with id " + article.Id); } catch (RepositoryException re) { throw new ServiceException("Repositiry ex: " + re.Message); } catch (Exception ex) { throw new ServiceException(ex.Message); } }
public void Update(New news) { _newRepository.Update(news); }
public void Update(News entity) { _newRepository.Update(entity); }
public bool Update(News entity) { return(newRepository.Update(entity)); }