public PartialViewResult PopularTags() { using (UnitOfWorkManager.NewUnitOfWork()) { var popularTags = _topicTagService.GetPopularTags(20); var viewModel = new PopularTagViewModel { PopularTags = popularTags }; return PartialView(viewModel); } }
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 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); } }