public PartialViewResult PopularTags()
 {
     
         var popularTags = _topicTagService.GetPopularTags(20);
         var viewModel = new PopularTagViewModel { PopularTags = popularTags };
         return PartialView("_PopularTags", viewModel);
     
 }
Exemple #2
0
 public PartialViewResult PopularTags()
 {
     using (UnitOfWorkManager.NewUnitOfWork())
     {
         var popularTags = _topicTagService.GetPopularTags(20);
         var viewModel   = new PopularTagViewModel {
             PopularTags = popularTags
         };
         return(PartialView(viewModel));
     }
 }
Exemple #3
0
 public PartialViewResult PopularTags(int amountToTake)
 {
     using (UnitOfWorkManager.NewUnitOfWork())
     {
         var cacheKey = string.Concat("PopularTags", amountToTake, UsersRole.Id);
         var viewModel = CacheService.Get<PopularTagViewModel>(cacheKey);
         if (viewModel == null)
         {
             var allowedCategories = _categoryService.GetAllowedCategories(UsersRole);
             var popularTags = _topicTagService.GetPopularTags(amountToTake, allowedCategories);
             viewModel = new PopularTagViewModel { PopularTags = popularTags };
             CacheService.Set(cacheKey, viewModel, CacheTimes.SixHours);
         }
         return PartialView(viewModel);
     }
 }
Exemple #4
0
 public PartialViewResult PopularTags(int amountToTake)
 {
     using (UnitOfWorkManager.NewUnitOfWork())
     {
         var cacheKey  = string.Concat("PopularTags", amountToTake, UsersRole.Id);
         var viewModel = _cacheService.Get <PopularTagViewModel>(cacheKey);
         if (viewModel == null)
         {
             var allowedCategories = _categoryService.GetAllowedCategories(UsersRole);
             var popularTags       = _topicTagService.GetPopularTags(amountToTake, allowedCategories);
             viewModel = new PopularTagViewModel {
                 PopularTags = popularTags
             };
             _cacheService.Set(cacheKey, viewModel, CacheTimes.SixHours);
         }
         return(PartialView(viewModel));
     }
 }
        public virtual PartialViewResult PopularTags(int amountToTake)
        {
            var loggedOnUsersRole = LoggedOnReadOnlyUser.GetRole(RoleService);

            var cacheKey  = string.Concat("PopularTags", amountToTake, loggedOnUsersRole.Id);
            var viewModel = CacheService.Get <PopularTagViewModel>(cacheKey);

            if (viewModel == null)
            {
                var allowedGroups = _groupService.GetAllowedGroups(loggedOnUsersRole, LoggedOnReadOnlyUser?.Id);
                var popularTags   = _topicTagService.GetPopularTags(amountToTake, allowedGroups);
                viewModel = new PopularTagViewModel {
                    PopularTags = popularTags
                };
                CacheService.Set(cacheKey, viewModel, CacheTimes.SixHours);
            }
            return(PartialView(viewModel));
        }
        public PartialViewResult PopularTags(int amountToTake)
        {
            var loggedOnReadOnlyUser = User.GetMembershipUser(MembershipService);
            var loggedOnUsersRole    = loggedOnReadOnlyUser.GetRole(RoleService);

            var cacheKey  = string.Concat("PopularTags", amountToTake, loggedOnUsersRole.Id);
            var viewModel = CacheService.Get <PopularTagViewModel>(cacheKey);

            if (viewModel == null)
            {
                var allowedCategories = _categoryService.GetAllowedCategories(loggedOnUsersRole);
                var popularTags       = _topicTagService.GetPopularTags(amountToTake, allowedCategories);
                viewModel = new PopularTagViewModel {
                    PopularTags = popularTags
                };
                CacheService.Set(cacheKey, viewModel, CacheTimes.SixHours);
            }
            return(PartialView(viewModel));
        }
Exemple #7
0
 public PartialViewResult PopularTags(int amountToTake)
 {
     using (UnitOfWorkManager.NewUnitOfWork())
     {
         PopularTagViewModel viewModel;
         var cacheKey   = string.Concat("PopularTags", amountToTake, UsersRole.Id);
         var cachedData = _cacheService.Get(cacheKey);
         if (cachedData == null)
         {
             var allowedCategories = _categoryService.GetAllowedCategories(UsersRole);
             var popularTags       = _topicTagService.GetPopularTags(amountToTake, allowedCategories);
             viewModel = new PopularTagViewModel {
                 PopularTags = popularTags
             };
             _cacheService.Set(cacheKey, viewModel, AppConstants.LongCacheTime);
         }
         else
         {
             viewModel = (PopularTagViewModel)cachedData;
         }
         return(PartialView(viewModel));
     }
 }
Exemple #8
0
        public ActionResult PopularTags()
        {
            List <TagCount> tagsResult = new List <TagCount>();

            var allCorkboards = corkboardDbContext.Corkboards.ToList();

            List <int> allCorkboardId = new List <int>();

            foreach (var item in allCorkboards)
            {
                allCorkboardId.Add(item.Cid);
            }

            List <string> allTags = new List <string>();

            var allPushpins = pushpinDbContext.Pushpins.ToList();

            foreach (var eachpushpin in allPushpins)
            {
                string theTagForEachPushpin = eachpushpin.Tags;
                var    splitedTag           = theTagForEachPushpin.Split(',');
                foreach (var item in splitedTag)
                {
                    if (!allTags.Contains(item))
                    {
                        allTags.Add(item);
                    }
                }
            }

            foreach (var eachTag in allTags)
            {
                Dictionary <int, string> uniqueCorkboardCheckDict = new Dictionary <int, string>();
                int uniqueCcCount       = 0;
                int ppCount             = pushpinDbContext.Pushpins.Where(pp => pp.Tags.Contains(eachTag)).Count();
                var pushpinsForEachTags = pushpinDbContext.Pushpins.Where(pp => pp.Tags.Contains(eachTag)).ToList();

                foreach (var ePFET in pushpinsForEachTags)
                {
                    if (!uniqueCorkboardCheckDict.ContainsKey(ePFET.CorkboardId))
                    {
                        uniqueCcCount += 1;
                        uniqueCorkboardCheckDict[ePFET.CorkboardId] = "done";
                    }
                }

                TagCount newTag = new TagCount();

                newTag.tag            = eachTag;
                newTag.pushpinCount   = ppCount;
                newTag.corkboardCount = uniqueCcCount;

                tagsResult.Add(newTag);
            }

            var newTagResult = tagsResult.OrderByDescending(tr => tr.pushpinCount).Take(5).ToList();

            var viewModel = new PopularTagViewModel
            {
                tagSearchResult = newTagResult
            };

            return(View(viewModel));
        }