Blog.Logic.Core.PostsLogic.GetPost C# (CSharp) 메소드

GetPost() 공개 메소드

public GetPost ( int postId ) : Post
postId int
리턴 Blog.Common.Contracts.Post
        public Post GetPost(int postId)
        {
            try
            {
                var db = _postRepository.Find(a => a.PostId == postId, null, "Tags,User,Communities").FirstOrDefault();
                if (db == null)
                {
                    return new Post().GenerateError<Post>((int)Constants.Error.RecordNotFound,
                        string.Format("Cannot find post with Id {0}", postId));
                }

                return EntityToDtoPostCleanUp(db, postId);
            }
            catch (Exception ex)
            {
                throw new BlogException(ex.Message, ex.InnerException);
            }
        }