public ListBlock <LinkDetails> GetMostValuedLinksForUser(long userId, int startIndex, int count) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } ListBlock <Link> links; try { links = LinkDao.ListForUserRated(userId, startIndex, count); } catch (InstanceNotFoundException <Link> ) { return(new ListBlock <LinkDetails>(startIndex, false)); } catch (NoMoreItemsException <Link> ) { return(new ListBlock <LinkDetails>(startIndex, false)); } List <LinkDetails> details = new List <LinkDetails>(); foreach (Link link in links) { UserProfile user; try { user = UserDao.Find(link.userId); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InternalErrorException(ex); } int rating = RatingDao.CalculateValueForLink(link.linkId); details.Add(new LinkDetails(link.linkId, link.userId, user.userLogin, link.movieId, link.name, link.description, link.url, rating, link.reportRead.GetValueOrDefault(), link.date)); } return(new ListBlock <LinkDetails>(details, links.Index, links.HasMore)); }