Exemple #1
0
        public List <SubWrapped> Wrap(List <Sub> subs, User currentUser = null)
        {
            var wrapped = new List <SubWrapped>();

            foreach (var sub in subs)
            {
                wrapped.Add(new SubWrapped(sub));
            }

            var subscribed = currentUser != null?_subDao.GetSubscribedSubsForUser(currentUser.Id) : new List <Guid>();

            foreach (var item in wrapped)
            {
                if (currentUser != null)
                {
                    item.IsSubscribed = subscribed.Contains(item.Sub.Id);
                }

                if (item.Sub.Subscribers < 100 && !(currentUser != null && currentUser.IsAdmin))
                {
                    item.FuzzSubscribers(_cache.GetAcquire("sub." + item.Sub.Id + ".fuzzed",
                                                           TimeSpan.FromSeconds(30),
                                                           () => StringHelper.Fuzz(item.Sub.Subscribers)));
                }
            }

            return(wrapped);
        }
Exemple #2
0
 public List <Guid> GetSubscribedSubIds()
 {
     //todo: optimize
     return(_userContext.CurrentUser != null?
            _subDao.GetSubscribedSubsForUser(_userContext.CurrentUser.Id) : _subDao.GetDefaultSubs());
 }
 public List <string> GetSubscribedSubNames()
 {
     // todo: optimize
     return(_userContext.CurrentUser != null?_subDao.GetSubscribedSubsForUser(_userContext.CurrentUser.UserName).Select(x => x.Name).ToList() : _subDao.GetDefaultSubs().Select(x => x.Name).ToList());
 }