public static List<GenreModel> GetGenres() { var repository = new GenreRepository(); //ViewData["Genres"] = return repository.GetGenres().Select(g => new GenreModel { GenreId = g.GenreId, Name = g.Name, Description = g.Description }) .ToList(); }
public static AlbumModel AlbumToAlbumModel(Album album) { var model = new AlbumModel() { Id = album.Id, Title = album.Title, Price = album.Price }; var genreRepository = new GenreRepository(); model.Genre = genreRepository.GetGenre(album.GenreId); var artistRepository = new ArtistRepository(); model.Artist = artistRepository.GetArtist(album.ArtistId); return model; }
public static AlbumsModel GetAlbumsModel(int? genreId) { var albumRepository = new AlbumRepository(); var model = new AlbumsModel(); model.Albums = albumRepository.GetAlbums(genreId) .Select( album => AlbumToAlbumModel(album)) .ToList(); if (genreId.HasValue) { var genreRepository = new GenreRepository(); model.Genre = genreRepository.GetGenre((int)genreId); } return model; }