Skip to content

Instantly share code, notes, and snippets.

@carlwoodhouse
Last active October 14, 2015 09:45
Show Gist options
  • Save carlwoodhouse/c8ad856585772134eedc to your computer and use it in GitHub Desktop.
Save carlwoodhouse/c8ad856585772134eedc to your computer and use it in GitHub Desktop.
var contentItemIdsByLetter = this.cacheManager.Get(
string.Concat("Patient.Contenttypes.Az.Ids.For.", letter),
ctx => {
ctx.Monitor(this.clock.When(Timespan.FromDays(1)));
return this.letterRepository.Fetch(x => x.Title.StartsWith(letter)).toList();
}
var items = this.cacheManager.Get(
string.Concat("Patient.Contenttypes.Az.Items.For.", letter, ".By.", contentType),
ctx => {
ctx.Monitor(this.clock.When(Timespan.FromDays(1)));
var content = this.contentManager.GetMany(contentItemIdsByLetter.Select(x => x.ContentItemId), VersionOptions.Published)
.Where(x => x.ContentType.Name == contentType);// im not sure if you can pass contentypes to getmany?
var altTitles = new List<KeyValuePair>();
foreach (var contentItem in content)
{
var titles = contentItemIdsByLetter.Where(x => x.ContentItemId == contentItem.Id);
foreach (var title in titles)
{
altTitles.Add(new KeyValuePair(title, contentItem.As<IAliasAspect>().Path));
}
}
return altTitles;
}
// do something with items, like display them :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment