public async Task <IActionResult> Detail(int id) { Genre genre = await _genres.GetById(id); if (genre != null) { ICollection <Movie> movies = await _genres.GetMovies(id); var detailModel = new GenreDetailModel { Id = genre.Id, Name = genre.Name, Movies = movies .Select(movie => new KeyValuePair <int, string>(movie.Id, movie.Title)) .ToDictionary(kvp => kvp.Key, kvp => kvp.Value) }; return(View(detailModel)); } return(NotFound()); }