Пример #1
0
        public ListBlock <LinkDetails> GetLinksForUser(long userId, int startIndex, int count)
        {
            if (!UserDao.Exists(userId))
            {
                throw new InstanceNotFoundException <UserProfileDetails>("userId", userId);
            }

            ListBlock <Link> links;

            try
            {
                links = LinkDao.ListForUser(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));
        }
Пример #2
0
 public List <Link> ListLinks(UserProfile user)
 {
     return(LinkDao.ListForUser(user.userId, 0, 1000));
 }