public void Add(Post post) { Post query = _postRepository.Add(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); } PostTag postTag = new PostTag() { PostID = query.ID, TagID = tagId, }; _postTagRepository.Add(postTag); } } }
public void CreatePost(Post Post) { _postsRepository.Add(Post); SavePost(); if (!string.IsNullOrEmpty(Post.Tags)) { string[] tags = Post.Tags.Split(','); foreach (var item in tags) { string alias = StringHelper.ToUnsignString(item); if (_tagRepository.Count(x => x.ID == alias) == 0) { Tag tag = new Tag(); tag.ID = alias; tag.Name = item; _tagRepository.Add(tag); } PostTag postTag = new PostTag(); postTag.PostID = Post.ID; postTag.TagID = alias; _postTagRepository.Add(postTag); } } }
public Post Add(Post post) { var _post = _postRepository.Add(post); _unitOfWork.Commit(); if (!string.IsNullOrEmpty(post.Tags)) { string[] tags = post.Tags.Split(','); for (var i = 0; i < tags.Length; i++) { var tagId = StringHelper.ToUnsignString(tags[i]); if (_tagRepository.Count(x => x.ID == tagId) == 0) { Tag tag = new Tag(); tag.ID = tagId; tag.Name = tags[i]; tag.Type = CommonConstants.PostTag; _tagRepository.Add(tag); } PostTag postTag = new PostTag(); postTag.PostID = post.ID; postTag.TagID = tagId; _postTagRepository.Add(postTag); } } return(_post); }
public Post Add(Post post) { var _post = _postRepository.Add(post); SaveChange(); if (!string.IsNullOrEmpty(_post.Tags)) { string[] ListTags = _post.Tags.Split(','); foreach (var item in ListTags) { var TagID = StringHelper.ToUnsignString(item); if (_tagRepository.Count(s => s.ID == TagID) == 0) { Tag tag = new Tag(); tag.ID = TagID; tag.Name = item; tag.Type = CommonConstants.PostTag; _tagRepository.Add(tag); } PostTag postTag = new PostTag(); postTag.PostID = _post.ID; postTag.TagID = TagID; _postTagRepository.Add(postTag); } } return(_post); }
public void Add(Post post) { _postRepository.Add(post); _unitOfWork.Commit(); if (!string.IsNullOrEmpty(post.Tags)) { string[] tags = post.Tags.Split(','); foreach (var tagItem in tags) { Tag tag = new Tag(); var tagId = StringHelper.ToUnsignString(tagItem); if (_tagRepository.Count(x => x.ID == tagId) == 0) { tag.ID = tagId; tag.Name = tagItem; tag.Type = CommonConstant.PostTag; _tagRepository.Add(tag); } PostTag postTag = new PostTag(); postTag.PostID = post.ID; postTag.TagID = tagId; _postTagRepository.Add(postTag); _unitOfWork.Commit(); } } }
/// <summary> /// Add a new PostTag record /// </summary> /// <param name="postTag">Compound Key</param> /// <returns>Qualified PostTag</returns> public PostTag Add(PostTag postTag) { var entity = _postTagRepository.Add(Mapper.Map <PostTag, PostTagEntity>(postTag)); postTag.PostTagId = entity.PostTagId; return(postTag); }
public void Add(PostTag postTag) { _postTagRepository.Add(postTag); }
public IActionResult Post(PostTag postTag) { _postTagRepository.Add(postTag); return(Ok()); }
public PostTag Add(PostTag postTag) { return(_postTagRepository.Add(postTag)); }
public IActionResult Post(PostTag postTag) { _postTagRepo.Add(postTag); return(CreatedAtAction("Details", new { id = postTag.Id }, postTag)); }