public async Task <Recordlabel> AddRecordlabel(Recordlabel recordlabel) { await _context.Recordlabels.AddAsync(recordlabel); await _context.SaveChangesAsync(); return(recordlabel); }
public async Task <ActionResult <Recordlabel> > AddLabel(Recordlabel recordlabel) { try { return(new OkObjectResult(await _labelService.AddRecordlabel(recordlabel))); } catch (Exception ex) { return(new StatusCodeResult(500)); } }
public async Task <SongAddDTO> AddSong(SongAddDTO song) { try { // voor DTO Song newSong = _mapper.Map <Song>(song); newSong.SongId = Guid.NewGuid(); foreach (var artistId in song.ArtistIds) { Artist artist = await GetArtistByArtistId(artistId); if (artist != null) { await _songRepository.AddSongArtist(new SongArtist() { SongArtistId = Guid.NewGuid(), SongId = newSong.SongId, ArtistId = artistId, }); } } Recordlabel recordlabel = await GetRecordlabelById(song.RecordLabelId); if (recordlabel != null) { newSong.LabelId = recordlabel.RecordLabelId; } await _songRepository.AddSong(newSong); return(song); } catch (Exception ex) { throw ex; } }
public async Task <List <Song> > GetSongsByRecordlabelName(string labelName) { try { Recordlabel recordlabel = await _recordlabelRepository.GetRecordlabelByName(labelName); if (recordlabel != null) { List <Song> songsByRecordlabel = new List <Song>(); List <Song> songs = await GetSongs(); if (songs != null) { foreach (var song in songs) { if (song.LabelId == recordlabel.RecordLabelId) { songsByRecordlabel.Add(song); } } return(songsByRecordlabel); } else { throw new ArgumentException("Database has no songs yet"); } } else { throw new ArgumentException("Recordlabel doesn't exist"); } // return await _songRepository.GetSongsByRecordlabelName(labelName); } catch (Exception ex) { throw ex; } }
public async Task <Recordlabel> AddRecordlabel(Recordlabel recordlabel) { await _recordlabelRepository.AddRecordlabel(recordlabel); return(recordlabel); }