public ActionResult Create() { if (_cacheManager == null) _cacheManager = new VideoCacheManager(HttpContext, _videoRepository); ViewBag.Categories = CategoriesFormatter.FormatCategories(_videoRepository.AdminCategories, false); return View(); }
// GET: Admin/Videos public ActionResult Index() { if (_cacheManager == null) _cacheManager = new VideoCacheManager(HttpContext, _videoRepository); var model = _cacheManager.Get("All") ?? _videoRepository.Videos; return View(model); }
private void FillModelWithVideos(SearchViewModel searchModel, int? page) { _cacheManager = new VideoCacheManager(HttpContext, _videosRepository); if (page == null) { var cache = _cacheManager.Get("All"); if (cache == null) { var clips = _videosRepository.Videos; searchModel.Videos = clips.Videos; searchModel.TotalVideos = clips.TotalVideos; } else { searchModel.Videos = cache.Videos; searchModel.TotalVideos = cache.TotalVideos; } } else { VideoDataResult result = null; var categoryCache = _cacheManager.Get(searchModel.Category); if (!string.IsNullOrWhiteSpace(searchModel.SearchContent) || categoryCache == null) { result = _videosRepository. Search(searchModel.Category, searchModel.SearchContent, searchModel.SortBy, searchModel.SortDirection.Equals("Descending") ? true : false, searchModel.PageNumber, searchModel.ClipsPerPage); } else { result = categoryCache; } searchModel.Videos = result.Videos; searchModel.TotalVideos = result.TotalVideos; searchModel.Cart = ExtractCartFromCookie(); } }
public ActionResult Edit(int id) { if (_cacheManager == null) _cacheManager = new VideoCacheManager(HttpContext, _videoRepository); return View(_videoRepository.Get(id)); }