Example #1
0
        public async Task <Comment> FindAsync(int id)
        {
            FindReply c = await commentsThingClient.FindAsync(new FindRequest()
            {
                Id = id
            });

            return(c.ToComment());
        }
Example #2
0
        public async Task <Photo> FindAsync(int id)
        {
            FindReply p = await photosThingClient.FindAsync(new FindRequest()
            {
                Id = id
            });

            return(p.ToPhoto());
        }
Example #3
0
        public async Task <Comment> FindAsync(int id)
        {
            FindReply c = await serviceClient.FindAsync(new FindRequest()
            {
                Id = id
            });

            return(new Comment {
                Id = c.Id, PhotoId = c.PhotoId, UserName = c.UserName, Subject = c.Subject, Body = c.Body, SubmittedOn = c.SubmittedOn.ToDateTime()
            });
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="threadId">The ID of the database.</param>
        /// <param name="collectionName">The human-readable name for the database.</param>
        /// <param name="query"></param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public async Task <IList <T> > FindAsync <T>(ThreadId threadId, string collectionName, Query query, CancellationToken cancellationToken = default)
        {
            FindRequest request = new()
            {
                DbID           = ByteString.CopyFrom(threadId.Bytes),
                CollectionName = collectionName,
                QueryJSON      = ByteString.CopyFrom(JsonSerializer.SerializeToUtf8Bytes(query))
            };

            FindReply reply = await _apiClient.FindAsync(request, headers : _threadContext.Metadata, cancellationToken : cancellationToken);

            return(reply.Instances.Select(i => JsonSerializer.Deserialize <T>(i.ToByteArray())).ToList());
        }
 public static Comment ToComment(this FindReply c) => new Comment(c.Id, c.PhotoId, c.UserName, c.Subject, c.Body, c.SubmittedOn.ToDateTime());
Example #6
0
 public static Photo ToPhoto(this FindReply p) => new Photo(p.Id, p.Title, p.PhotoFile.ToArray(), p.ImageMimeType, p.Description, p.CreatedDate.ToDateTime(), p.UserName, null);