public static Song ToDomainModel(this SongCreateViewModel songCreateViewModel) { var song = new Song(songCreateViewModel.Name, songCreateViewModel.SongGenres); song.SongID = songCreateViewModel.SongID; song.Artist = songCreateViewModel.Artist; //song.Genres = UpdateGenres.GetGenresFromIntList(songCreateViewModel.SelectedGenres); return song; }
public static void AddOrUpdateArtist(StoreContext db, Song song, Artist artistToAdd) { if (song.Artist == artistToAdd) //new artist is the same as the original artist { //do nothing } else { song.Artist = artistToAdd; } }
public static void AddOrUpdateSongGenre(StoreContext context, Song song, IEnumerable<Genre> songGenres) { if (songGenres != null) { //drop existing song genres song.Genres.Clear(); foreach (var songGenre in songGenres) { song.Genres.Add(songGenre); } } }
public static void AddOrUpdateSongGenre(StoreContext context, Song song, List<int> genreIDs) { List<Genre> genres = GetGenresFromIntList(context, genreIDs); AddOrUpdateSongGenre(context, song, genres); }