示例#1
0
        public async Task <IActionResult> Create()
        {
            var cachedSelectListGenres = await _memoryCache.GetOrCreateAsync("Genres", async entry =>
            {
                entry.SlidingExpiration = TimeSpan.FromHours(4);
                var movieGenres         = await movieServices.GetGenresAsync();
                return(movieGenres.Select(g => new SelectListItem(g.GenreType, g.GenreType)));
            });

            var newMovie = new MovieViewModel
            {
                GenreList = cachedSelectListGenres
            };

            return(View(newMovie));
        }