예제 #1
0
 public void Update(Post post)
 {
     this._postRepository.Update(post);
     _unitOfWork.Commit();
     if (!string.IsNullOrEmpty(post.Tags))
     {
         string[] listTag = post.Tags.Split(',');
         for (int i = 0; i < listTag.Length; i++)
         {
             var tagId = StringHelper.ToUnsignString(listTag[i]);
             if (_tagReponsitory.Count(x => x.ID == tagId) == 0)
             {
                 Tag tag = new Tag()
                 {
                     ID   = tagId,
                     Name = listTag[i],
                     Type = CommonConstant.PostTag,
                 };
                 _tagReponsitory.Add(tag);
             }
             int coutPostTag = _postTagRepository.GetMulti(x => (x.PostID == post.ID && x.TagID == tagId)).Count();
             if (coutPostTag == 0)
             {
                 PostTag postTag = new PostTag()
                 {
                     PostID = post.ID,
                     TagID  = tagId,
                 };
                 _postTagRepository.Add(postTag);
             }
         }
     }
 }
예제 #2
0
 public IEnumerable <PostTag> GetAll(string keyword)
 {
     if (string.IsNullOrEmpty(keyword))
     {
         return(_postTagRepository.GetAll());
     }
     else
     {
         return(_postTagRepository.GetMulti(x => x.PostID.ToString().Contains(keyword) ||
                                            x.TagID.Contains(keyword)));
     }
 }
예제 #3
0
        public IEnumerable <Tag> GetListTagByPostId(int id)
        {
            var result = _postTagRepository.GetMulti(s => s.PostID == id, new string[] { "Tag" }).Select(y => y.Tag);

            return(result);
        }
예제 #4
0
 public List <Tag> GetListTags(int id)
 {
     return(_postTagRepository
            .GetMulti(x => x.PostID == id, new string[] { "Tag" })
            .Select(x => x.Tag).ToList());
 }
예제 #5
0
 public IEnumerable <Tag> GetListTagByPostId(int id)
 {
     return(_postTagRepository.GetMulti(x => x.PostID == id, new string[] { "Tag" }).Select(y => y.Tag));
 }