Ejemplo n.º 1
0
 /// <summary>
 /// Convert the user record into an entity.
 /// </summary>
 /// <param name="source">The record to convert.</param>
 /// <returns>The rebuilt user entity.</returns>
 public User Map(UserRecord source)
 {
     return(new User()
     {
         Id = source.Id,
         Username = source.Username,
         Email = source.Email,
         PasswordHash = source.PasswordHash,
         JoinedDate = source.JoinedDate,
         PostKarma = source.PostKarma,
         CommentKarma = source.CommentKarma
     });
 }
Ejemplo n.º 2
0
        public Tuple <VoteRecord, UserRecord> Reverse(Vote destination)
        {
            VoteRecord voteRec = new VoteRecord()
            {
                Id           = destination.Id,
                UserId       = destination.User.Id,
                ResourceId   = destination.ResourceId,
                ResourceType = destination.ResourceType,
                Direction    = destination.Direction
            };

            UserRecord userRecord = userRecordMapper.Reverse(destination.User);

            return(Tuple.Create <VoteRecord, UserRecord>(voteRec, userRecord));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Convert the post back into it's record form.
        /// </summary>
        /// <param name="destination">The entity/</param>
        /// <returns>The rebuilt record.</returns>
        public Tuple <PostRecord, UserRecord, Tuple <SpaceRecord, UserRecord> > Reverse(Post destination)
        {
            PostRecord p = new PostRecord {
                Id           = destination.Id,
                UserId       = destination.User.Id,
                Type         = destination.Type,
                Title        = destination.Title,
                Body         = destination.Body,
                CreationDate = destination.CreationDate,
                WasUpdated   = destination.WasUpdated,
                WasDeleted   = destination.WasDeleted,
                CommentCount = destination.CommentCount,
                Upvotes      = destination.Upvotes,
                Downvotes    = destination.Downvotes,
                SpaceId      = destination.Space.Id
            };

            UserRecord u = userMapper.Reverse(destination.User);
            Tuple <SpaceRecord, UserRecord> s = spaceMapper.Reverse(destination.Space);

            return(Tuple.Create(p, u, s));
        }
Ejemplo n.º 4
0
 private User Map(UserRecord rec) => factory.Create(rec.Id, rec.Username, rec.Email, rec.PasswordHash, rec.JoinedDate, rec.PostKarma, rec.CommentKarma);
Ejemplo n.º 5
0
 private Comment Mapper(CommentRecord commentRec, UserRecord userRec) => this.commentMapper.Map(Tuple.Create(commentRec, userRec));