private void SetTags(string p, Article article)
 {
     IEnumerable<string> tags = TagService.SplitTags(p).Distinct();
     if (article.Tags != null)
     {
         article.Tags.Clear();
     }
     else
     {
         article.Tags = new List<Tag>();
     }
     foreach (var tag in tags)
     {
         var tmp = _unitOfWork.TagRepository.GetTagByName(tag.Trim());
         if (tmp == null)
         {
             tmp = new Tag
             {
                 Name = tag.Trim()
             };
             _unitOfWork.TagRepository.Insert(tmp);
             _unitOfWork.Save();
         }
         article.Tags.Add(tmp);
     }
 }
 private void AddArticle(ArticleViewModel model)
 {
     var article = new Article
     {
         Title = String.IsNullOrWhiteSpace(model.Title) ? "..." : model.Title,
         Description = model.Description,
         UserId = WebSecurity.CurrentUserId,
     };
     if (model.Tags != null)
     {
         SetTags(model.Tags, article);
     }
     _unitOfWork.ArticleRepository.Insert(article);
     _unitOfWork.Save();
     ClearCache();
 }