コード例 #1
0
        /// <inheritdoc/>
        public async Task <Bookmark> GetBookmarkFromUrlAsync(string url)
        {
            _logger.LogDebug($"Searching Bookmarks for url equal to '{url}'.");
            Query         query         = _bookmarksCollection.WhereEqualTo("url", url); //TODO: change "url" to use reflection
            QuerySnapshot querySnapshot = await query.GetSnapshotAsync();

            if (querySnapshot.Documents.Any())
            {
                _logger.LogDebug($"Bookmark found with url equal to '{url}'.");
                var bookmarkDocument = querySnapshot.First();
                var bookmark         = bookmarkDocument.ConvertTo <Bookmark>();
                bookmark.Path = bookmarkDocument.Reference.Path;

                return(bookmark);
            }
            else
            {
                _logger.LogInformation($"No Bookmark found with url equal to '{url}'");
                return(null);
            }
        }