Exemple #1
0
 /// <summary>
 /// Find a space by it's numeric ID.
 /// </summary>
 /// <param name="id">The ID to look for.</param>
 /// <returns>The space found (if any).</returns>
 public async Task <Space?> FindById(int id)
 {
     return((await Connection.QueryAsync <SpaceRecord, UserRecord, Space>(
                 @"SELECT * FROM Space LEFT JOIN ""User"" ON Space.UserId = ""User"".Id WHERE Space.Id = @Id",
                 (SpaceRecord s, UserRecord u) => mapper.Map(Tuple.Create(s, u)),
                 new { Id = id }
                 )).FirstOrDefault());
 }
Exemple #2
0
 public Subscription Map(Tuple <SubscriptionRecord, UserRecord, Tuple <SpaceRecord, UserRecord> > source)
 {
     return(new Subscription()
     {
         Id = source.Item1.Id,
         User = _userRecordMapper.Map(source.Item2),
         Space = _spaceRecordMapper.Map(source.Item3)
     });
 }
Exemple #3
0
 /// <summary>
 /// Convert the record into it's entity form.
 /// </summary>
 /// <param name="source">The source record.</param>
 /// <returns>The entity.</returns>
 public Post Map(Tuple <PostRecord, UserRecord, Tuple <SpaceRecord, UserRecord> > source)
 {
     return(new Post()
     {
         Id = source.Item1.Id,
         User = userMapper.Map(source.Item2),
         Type = source.Item1.Type,
         Title = source.Item1.Title,
         Body = source.Item1.Body,
         CreationDate = source.Item1.CreationDate,
         WasUpdated = source.Item1.WasUpdated,
         WasDeleted = source.Item1.WasDeleted,
         CommentCount = source.Item1.CommentCount,
         Space = spaceMapper.Map(source.Item3),
         Upvotes = source.Item1.Upvotes,
         Downvotes = source.Item1.Downvotes
     });
 }