Exemple #1
0
 public Tuple <SubscriptionRecord, UserRecord, Tuple <SpaceRecord, UserRecord> > Reverse(Subscription destination)
 {
     return(Tuple.Create(
                new SubscriptionRecord()
     {
         Id = destination.Id, SpaceId = destination.Space.Id, UserId = destination.User.Id
     },
                _userRecordMapper.Reverse(destination.User),
                _spaceRecordMapper.Reverse(destination.Space)
                ));
 }
Exemple #2
0
        /// <summary>
        /// Add a new space to the database.
        /// </summary>
        /// <param name="entity">The space to add.</param>
        public async Task Add(Space entity)
        {
            SpaceRecord rec = mapper.Reverse(entity).Item1;

            entity.Id = await Connection.QueryFirstOrDefaultAsync <int>(
                @"INSERT INTO Space(
                        Name,
                        Description,
                        CreationDate,
                        SubscriptionCount,
                        UserId,
                        IsDefault
                        ) VALUES (
                        @Name,
                        @Description,
                        @CreationDate,
                        @SubscriptionCount,
                        @UserId,
                        @IsDefault
                        ) RETURNING Id;", rec
                );
        }
Exemple #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));
        }