protected override void Process(LinqExtender.Interface.IModify <Tag> items) { object tagList = Bucket.Instance.For.Item(TagColums.ListMode).Value; TagListMode tagListMode = tagList == null ? TagListMode.Popular : (TagListMode)tagList; if (tagListMode == TagListMode.Popular) { object tagsPeriod = Bucket.Instance.For.Item(TagColums.Period).Value; TagPeriod period = tagsPeriod == null ? TagPeriod.Day : (TagPeriod)tagsPeriod; int score = Convert.ToInt32(Bucket.Instance.For.Item(TagColums.Score).Value ?? "0"); int count = (int)Bucket.Instance.For.Item(TagColums.Count).Value; if (count > 200) { throw new Exception("Tag count should be less than 200"); } using (ITagRepository tagRepositoryRepo = repositoryFactory.CreateTagRepository()) { IEnumerable <Tag> tags = tagRepositoryRepo.GetPopularTags(period, count); // do the filter on score. if (score > 0) { tags = tags.Where(tag => tag.Score == score).Select(tag => tag); } items.AddRange(tags, true); } } else { object photoId = Bucket.Instance.For.Item(TagColums.PhotoId).Value; if (photoId == null) { throw new Exception("Must provide a valid photoId"); } using (ITagRepository tagRepositoryRepo = repositoryFactory.CreateTagRepository()) { items.AddRange(tagRepositoryRepo.GetTagsForPhoto((string)photoId)); } } }
protected override void Process(LinqExtender.Interface.IModify <Comment> items) { using (ICommentRepository commentRepositoryRepo = new CommentRepository(elementProxy)) { string photoId = (string)Bucket.Instance.For.Item(CommentColumns.PhotoId).Value; string commentId = (string)Bucket.Instance.For.Item(CommentColumns.Id).Value; if (string.IsNullOrEmpty(photoId)) { throw new Exception("Must have a valid photoId"); } int index = Bucket.Instance.Entity.ItemsToSkipFromStart; int itemsToTake = int.MaxValue; if (Bucket.Instance.Entity.ItemsToFetch != null) { itemsToTake = Bucket.Instance.Entity.ItemsToFetch.Value; } // get comments IEnumerable <Comment> comments = commentRepositoryRepo.GetComments(photoId); // filter if (!string.IsNullOrEmpty(commentId)) { var query = (from comment in comments where comment.Id == commentId select comment).Skip(index).Take(itemsToTake); comments = query; } else { var query = (from comment in comments select comment).Skip(index).Take(itemsToTake); comments = query; } items.AddRange(comments, true); } }