Blog.Logic.Core.TagsLogic.GetByPostId C# (CSharp) 메소드

GetByPostId() 공개 메소드

public GetByPostId ( int postId ) : List
postId int
리턴 List
        public List<Tag> GetByPostId(int postId)
        {
            var tags = new List<Tag>();
            try
            {
                var post = _postRepository.Find(a => a.PostId == postId, null, "Tags").FirstOrDefault();

                if (post != null)
                {
                    var db = _tagRepository.Find(a => a.Posts.Contains(post), null, string.Empty).ToList();
                    db.ForEach(a => tags.Add(TagMapper.ToDto(a)));
                }
            }
            catch (Exception ex)
            {
                throw new BlogException(ex.Message, ex.InnerException);
            }
            return tags;
        }