Exemple #1
0
        public ListBlock <LinkDetails> GetMostValuedLinksForLabel(string label, int startIndex, int count)
        {
            ListBlock <Link> links;

            try
            {
                links = LinkDao.ListForLabelRated(label, 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));
        }