public DictionaryBlock <string, long> GetLabelsForLink(long linkId, int startIndex, int count) { if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } ListBlock <Label> labels; try { labels = LabelDao.ListForLinkRated(linkId, startIndex, count); } catch (InstanceNotFoundException <Label> ) { return(new DictionaryBlock <string, long>(startIndex, false)); } catch (NoMoreItemsException <Label> ) { return(new DictionaryBlock <string, long>(startIndex, false)); } DictionaryBlock <string, long> details = new DictionaryBlock <string, long>(labels.Index, labels.HasMore); foreach (Label label in labels) { int rating = RatingDao.CalculateValueForLabel(label.text); details.Add(label.text, rating); } return(details); }
public DictionaryBlock <string, long> GetMostValuedLabels(int startIndex, int count) { ListBlock <Label> labels; try { labels = LabelDao.ListAllRated(startIndex, count); } catch (InstanceNotFoundException <Label> ) { return(new DictionaryBlock <string, long>(startIndex, false)); } catch (NoMoreItemsException <Label> ) { return(new DictionaryBlock <string, long>(startIndex, false)); } DictionaryBlock <string, long> details = new DictionaryBlock <string, long>(labels.Index, labels.HasMore); foreach (Label label in labels) { int rating = RatingDao.CalculateValueForLabel(label.text); details.Add(label.text, rating); } return(details); }