public PostView Map(Post post) { UserView userView = userMapper.Map(post.User); SpaceView spaceView = spaceMapper.Map(post.Space); VoteView? voteView = post.Vote != null?voteMapper.Map(post.Vote) : null; return(new PostView(post.Id, post.Type, post.Title, post.Body, userView, spaceView, post.CreationDate, post.CommentCount, post.WasUpdated, post.WasDeleted, post.Upvotes, post.Downvotes, voteView)); }
/// <summary> /// Create a new post DTO. /// </summary> /// <param name="id">The ID of the post.</param> /// <param name="type">The type flag of the post.</param> /// <param name="title">The title of the post.</param> /// <param name="body">The body of the post.</param> /// <param name="user">The OP.</param> /// <param name="space">The space it was submitted to..</param> /// <param name="creationDate">The date the post was created on.</param> /// <param name="commentCount">The comment countof the post</param> /// <param name="wasEditted">If the post has been editted</param> /// <param name="wasDeleted">If the post has been deleted.</param> /// <param name="vote">The vote of the user viewing it</param> public PostView(int id, PostType type, string title, string body, UserView user, SpaceView space, DateTime creationDate, int commentCount, bool wasEditted, bool wasDeleted, int upvotes, int downvotes, VoteView?vote = null) { Id = id; Type = type; Title = title; Body = body; User = user; Space = space; CreationDate = creationDate; CommentCount = commentCount; WasUpdated = wasEditted; WasDeleted = wasDeleted; Upvotes = upvotes; Downvotes = downvotes; Vote = vote; }