コード例 #1
0
 public List<Genre> GetGenreList()
 {
     using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities())
     {
         var genreList = db.Genres.ToList();
         return genreList;
     }
 }
コード例 #2
0
 public string GetGenre(int genreId)
 {
     using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities())
     {
         Genre genre = db.Genres.Single(x => x.GenreId == genreId );
         return genre.GenreName;
     }
 }
コード例 #3
0
 public void AddGenre(string genreToAdd)
 {
     using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities())
      {
         Genre genre = new Genre {GenreName = genreToAdd};
         db.Genres.Add(genre);
         db.SaveChanges();
      }
 }
コード例 #4
0
        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;
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
 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;
 }
コード例 #7
0
        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;
        }
コード例 #8
0
 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;
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 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();
          }
 }
コード例 #11
0
 public int GetAlbumID(string selectedItem)
 {
     using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities())
     {
         Album album = db.Albums.Single(x => x.AlbumTitle == selectedItem);
         return album.AlbumId;
     }
 }
コード例 #12
0
 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;
 }
コード例 #13
0
 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();
     }
 }
コード例 #14
0
 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;
 }
コード例 #15
0
 public List<Album> GetAlbumList()
 {
     using (CapstoneCDCatalogEntities db = new CapstoneCDCatalogEntities())
     {
         var albumList = db.Albums.ToList();
         return albumList;
     }
 }