Exemple #1
0
        public virtual ApiCommentServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCommentServerRequestModel request)
        {
            var response = new ApiCommentServerResponseModel();

            response.SetProperties(id,
                                   request.CreationDate,
                                   request.PostId,
                                   request.Score,
                                   request.Text,
                                   request.UserId);
            return(response);
        }
Exemple #2
0
        public virtual ApiCommentServerResponseModel MapEntityToModel(
            Comment item)
        {
            var model = new ApiCommentServerResponseModel();

            model.SetProperties(item.Id,
                                item.CreationDate,
                                item.PostId,
                                item.Score,
                                item.Text,
                                item.UserId);
            if (item.PostIdNavigation != null)
            {
                var postIdModel = new ApiPostServerResponseModel();
                postIdModel.SetProperties(
                    item.PostIdNavigation.Id,
                    item.PostIdNavigation.AcceptedAnswerId,
                    item.PostIdNavigation.AnswerCount,
                    item.PostIdNavigation.Body,
                    item.PostIdNavigation.ClosedDate,
                    item.PostIdNavigation.CommentCount,
                    item.PostIdNavigation.CommunityOwnedDate,
                    item.PostIdNavigation.CreationDate,
                    item.PostIdNavigation.FavoriteCount,
                    item.PostIdNavigation.LastActivityDate,
                    item.PostIdNavigation.LastEditDate,
                    item.PostIdNavigation.LastEditorDisplayName,
                    item.PostIdNavigation.LastEditorUserId,
                    item.PostIdNavigation.OwnerUserId,
                    item.PostIdNavigation.ParentId,
                    item.PostIdNavigation.PostTypeId,
                    item.PostIdNavigation.Score,
                    item.PostIdNavigation.Tag,
                    item.PostIdNavigation.Title,
                    item.PostIdNavigation.ViewCount);

                model.SetPostIdNavigation(postIdModel);
            }

            if (item.UserIdNavigation != null)
            {
                var userIdModel = new ApiUserServerResponseModel();
                userIdModel.SetProperties(
                    item.UserIdNavigation.Id,
                    item.UserIdNavigation.AboutMe,
                    item.UserIdNavigation.AccountId,
                    item.UserIdNavigation.Age,
                    item.UserIdNavigation.CreationDate,
                    item.UserIdNavigation.DisplayName,
                    item.UserIdNavigation.DownVote,
                    item.UserIdNavigation.EmailHash,
                    item.UserIdNavigation.LastAccessDate,
                    item.UserIdNavigation.Location,
                    item.UserIdNavigation.Reputation,
                    item.UserIdNavigation.UpVote,
                    item.UserIdNavigation.View,
                    item.UserIdNavigation.WebsiteUrl);

                model.SetUserIdNavigation(userIdModel);
            }

            return(model);
        }