Skip to content

Instantly share code, notes, and snippets.

@carlwoodhouse
Last active October 14, 2015 10:04
Show Gist options
  • Save carlwoodhouse/b7c69809e8a9fd0b2b14 to your computer and use it in GitHub Desktop.
Save carlwoodhouse/b7c69809e8a9fd0b2b14 to your computer and use it in GitHub Desktop.
var contentAzDefinitions = this.cacheManager.Get(
string.Concat("Patient.Contenttypes.Az.Ids.For.", letter),
ctx => {
ctx.Monitor(this.clock.When(Timespan.FromDays(1)));
var titleDefinitions = this.letterRepository.Fetch(x => x.Title.StartsWith(letter)).toList();
var content = this.contentManager.GetMany(titleDefinitions.Select(x => x.ContentItemId), VersionOptions.Published);
var items = new List<AzLinkDefinition>();
foreach(var titleDefinition in titleDefinitions)
{
var contentItem = content.FirstOrDefault(x => x.Id == titleDefinition.ContentItemId);
items.Add(new AzLinkDefinition { Title = titleDefinition.Title, Path = contentItem.As<IAliasAspect>().Path, ContentType = contentItem.ContentType.Name });
}
return items;
});
var itemsByLetter = contentAzDefinitions.Where(x => x.ContentType == contentType);
// do something here
}
class AzLinkDefinition
{
public string Title { get; set; }
public string Path { get; set; }
public string ContentType { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment