public void UpdateArticle(int articleId, string title, string content, string tags) { var article = _articleRepository.Get(articleId); article.Title = title; article.Content = content; if (tags != null) { // sterg legaturile cu tag-urile de la articolul repsectiv _articleTagsRepository.deleteAllArticleTagsBy(articleId); //Adaug tag-urile in bdd foreach (var tag in tags.Split("")) { _tagsRepository.Add(new Tags { Name = tag }); // iau tagul nou creat var recentlyCreatedTag = _tagsRepository.GetTagBy(tag); // Dupa care leg articolul de noile taguri; _articleTagsRepository.Add(new ArticleTags { Article = article, ArticleId = article.ArticleId, Tags = recentlyCreatedTag, TagsId = recentlyCreatedTag.TagsId }); } } _articleRepository.Update(article); }
public Tags GetTagBy(string tagName) { return(_tagsRepository.GetTagBy(tagName)); }