public IEnumerable <AlbumDTO> ListAlbums(AlbumFilter filter) { using (UnitOfWorkProvider.Create()) { _albumListQuery.Filter = filter; return(_albumListQuery.Execute() ?? new List <AlbumDTO>()); } }
public int GetAlbumIdByName(string albumName) { if (albumName == null) { throw new ArgumentNullException("Album service - GetAlbumIdByName(...) albumName cannot be null"); } using (UnitOfWorkProvider.Create()) { albumListQuery.Filter = new AlbumFilter { Name = albumName }; var album = albumListQuery.Execute().SingleOrDefault(); if (album == null) { throw new NullReferenceException("Album service - GetAlbumIdByName(...) album cannot be null(could not be found)"); } return(album?.ID ?? 0); } }
public IEnumerable <AlbumDTO> GetAllAlbumsForArtist(int artistId) { if (artistId < 1) { throw new ArgumentOutOfRangeException("Artist service - GetAllAlbumsForArtist(...) artistId cannot be lesser than 1"); } List <int> artistIds = new List <int> { artistId }; using (UnitOfWorkProvider.Create()) { albumListQuery.Filter = new AlbumFilter { ArtistIDs = artistIds }; return(albumListQuery.Execute()); } }