Beispiel #1
0
        /// <summary>
        /// Checks whether the target URI can receive pingbacks.
        /// </summary>
        /// <param name="targetUri">The target URI.</param>
        /// <returns><c>true</c> if target URI points to a <see cref="BlogEntry"/>, otherwise <c>false</c>.</returns>
        private bool IsTargetPingbackEnabled(string targetUri)
        {
            var match = Regex.Match(targetUri, ConfigurationManager.AppSettings["PingbackPattern"], RegexOptions.IgnoreCase);

            if (match.Success)
            {
                this.blogEntry = this.repository.BlogEntries
                    .AsNoTracking()
                    .Where(e => (e.Visible && e.PublishDate <= DateTime.Now))
                    .SingleOrDefault(e => e.HeaderUrl.Equals(match.Groups[1].Value));

                return this.blogEntry != null;
            }
            else
            {
                return false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns related <see cref="BlogEntry">BlogEntries</see>.
        /// </summary>
        /// <param name="entry">The <see cref="BlogEntry"/>.</param>
        /// <returns>
        /// The related <see cref="BlogEntry">BlogEntries</see>.
        /// </returns>
        private Task<BlogEntry[]> GetRelatedBlogEntries(BlogEntry entry)
        {
            var tagIds = entry.Tags.Select(t => t.Id).ToArray();

            var query = this.repository.BlogEntries
                .AsNoTracking()
                .Where(e => e.Visible && e.PublishDate <= DateTime.Now && e.Id != entry.Id)
                .Where(e => e.Tags.Any(t => tagIds.Contains(t.Id)))
                .OrderByDescending(e => e.Tags.Count(t => tagIds.Contains(t.Id)))
                .ThenByDescending(e => e.Created)
                .Take(3)
                .ToArrayAsync();

            return query;
        }