Adxstudio.Xrm.Forums.AttributeWithFetchFallbackCounterStrategy.GetForumThreadPostCountFromAttribute(Microsoft.Xrm.Sdk.Entity)

Here are the examples of the csharp api class Adxstudio.Xrm.Forums.AttributeWithFetchFallbackCounterStrategy.GetForumThreadPostCountFromAttribute(Microsoft.Xrm.Sdk.Entity) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

1. Example

Project: xRM-Portals-Community-Edition
Source File: AttributeCounterStrategy.cs
public int GetForumThreadPostCount(OrganizationServiceContext serviceContext, Entity forumThread)
		{
			if (forumThread == null) throw new ArgumentNullException("forumThread");

			var postCount = GetForumThreadPostCountFromAttribute(forumThread);

			return postCount == null
				? _fetchCounterStrategy.GetForumThreadPostCount(serviceContext, forumThread)
				: postCount.Value;
		}

2. Example

Project: xRM-Portals-Community-Edition
Source File: AttributeCounterStrategy.cs
public IDictionary<Guid, int> GetForumThreadPostCounts(OrganizationServiceContext serviceContext, IEnumerable<Entity> forumThreads)
		{
			if (forumThreads == null) throw new ArgumentNullException("forumThreads");

			var fromAttributes = forumThreads.Select(e => new Tuple<Entity, int?>(e, GetForumThreadPostCountFromAttribute(e))).ToArray();
			var fallbackEntities = fromAttributes.Where(e => e.Item2 == null).Select(e => e.Item1).ToArray();

			var counts = fromAttributes.ToDictionary(e => e.Item1.Id, e => e.Item2.GetValueOrDefault());

			foreach (var fetchCounts in _fetchCounterStrategy.GetForumThreadPostCounts(serviceContext, fallbackEntities))
			{
				counts[fetchCounts.Key] = fetchCounts.Value;
			}

			return counts;
		}