public List<Genre> GetGenreList() { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var genreList = db.Genres.ToList(); return genreList; } }
public string GetGenre(int genreId) { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { Genre genre = db.Genres.Single(x => x.GenreId == genreId ); return genre.GenreName; } }
public void AddGenre(string genreToAdd) { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { Genre genre = new Genre {GenreName = genreToAdd}; db.Genres.Add(genre); db.SaveChanges(); } }
public Album GetAlbum(string albumTitle) { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var album = db.Albums.FirstOrDefault(x => x.AlbumTitle.ToLower() == albumTitle.ToLower()); if (album != null) return album; } return null; }
public List<Song> GetSongListByGenre(string selectedItem) { var genreId = GetGenreId(selectedItem); using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var songList = db.Songs.Where(x => x.GenreId == genreId).Select(x => x); return songList.ToList(); } }
public bool DoesGenreExist(string genreToAdd) { bool result = false; using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var genre = db.Genres.FirstOrDefault(x => x.GenreName.ToLower() == genreToAdd.ToLower()); if(genre != null) result = true; } return result; }
public bool DoesAlbumExists(string albumTitle, int albumYear) { bool doesAlbumExist = false; using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var album = db.Albums.FirstOrDefault(x => x.AlbumTitle.ToLower() == albumTitle.ToLower()); if (album != null) doesAlbumExist = true; } return doesAlbumExist; }
public List<Album> DoesAlbumExists(string titleToSearchFor) { var album = new List<Album>(); { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { album = new List<Album> { db.Albums.FirstOrDefault(x => x.AlbumTitle.ToLower() == titleToSearchFor.ToLower()) }; if (album != null) return album; } } return null; }
public int GetGenreId(string selectedItem) { if (!DoesGenreExist(selectedItem)) AddGenre(selectedItem); else { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { Genre genre = db.Genres.Single(x => x.GenreName == selectedItem); return genre.GenreId; } } return GetGenreId(selectedItem); }
public void AddAlbum(string albumTitle, int albumYear, int albumRating, string artistTitle) { var artistId = SongService.ArtistService.GetArtistId(artistTitle); using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { Album album = new Album { AlbumTitle = albumTitle, AlbumYear = albumYear, AlbumRating = albumRating, ArtistId = artistId }; db.Albums.Add(album); db.SaveChanges(); } }
public int GetAlbumID(string selectedItem) { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { Album album = db.Albums.Single(x => x.AlbumTitle == selectedItem); return album.AlbumId; } }
public Album GetAlbum(int albumID) { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var album = db.Albums.FirstOrDefault(x => x.AlbumId == albumID); if (album != null) return album; } return null; }
public void UpdateAlbumRating(string oldAlbum, int rating) { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var newAlbum = db.Albums.FirstOrDefault(x => x.AlbumTitle == oldAlbum); newAlbum.AlbumRating = rating; db.SaveChanges(); } }
public List<Album> GetAlbumsByArtist(string artistToSearchFor) { var album = new List<Album>(); { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { album = db.Albums.Where(x => x.Artist.ArtistName == artistToSearchFor.ToLower()).ToList(); if (album != null) return album; } } return null; }
public List<Album> GetAlbumList() { using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities()) { var albumList = db.Albums.ToList(); return albumList; } }