override public RestfulCollection <Person> getPeople(HashSet <UserId> userId, GroupId groupId, CollectionOptions options, HashSet <String> fields, ISecurityToken token) { int first = options.getFirst(); int max = options.getMax(); Dictionary <string, Person> allPeople; HashSet <String> ids = GetIdSet(userId, groupId, token); #if AZURE using (var db = new AzureDbFetcher()) #else using (var db = new RayaDbFetcher()) #endif { allPeople = db.GetPeople(ids, fields, options); } var totalSize = allPeople.Count; var result = new List <Person>(); if (first < totalSize) { foreach (var id in ids) { if (!allPeople.ContainsKey(id)) { continue; } Person person = allPeople[id]; if (!token.isAnonymous() && id == token.getViewerId()) { person.isViewer = true; } if (!token.isAnonymous() && id == token.getOwnerId()) { person.isOwner = true; } result.Add(person); } // We can pretend that by default the people are in top friends order if (options.getSortBy().Equals(Person.Field.NAME.ToDescriptionString())) { result.Sort(new NameComparator()); } if (options.getSortOrder().Equals(SortOrder.descending)) { result.Reverse(); } result = result.GetRange(first, Math.Min(max, totalSize - first > 0 ? totalSize - first : 1)); } return(new RestfulCollection <Person>(result, options.getFirst(), totalSize)); }