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); } } } }
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))); } }
public IEnumerable <Tag> GetListTagByPostId(int id) { var result = _postTagRepository.GetMulti(s => s.PostID == id, new string[] { "Tag" }).Select(y => y.Tag); return(result); }
public List <Tag> GetListTags(int id) { return(_postTagRepository .GetMulti(x => x.PostID == id, new string[] { "Tag" }) .Select(x => x.Tag).ToList()); }
public IEnumerable <Tag> GetListTagByPostId(int id) { return(_postTagRepository.GetMulti(x => x.PostID == id, new string[] { "Tag" }).Select(y => y.Tag)); }