public void SongEdit(Models.Song song) { var dbSong = SongMapper.ToDatabase(song); _dbContext.Song.Update(dbSong); _dbContext.SaveChanges(); }
public void Save(Models.Song song) { var dbSong = SongMapper.ToDatabase(song); _dbContext.Song.Add(dbSong); _dbContext.SaveChanges(); }
public List <Models.Song> GetSongs(int id) { List <Models.Song> songs = new List <Models.Song>(); var couples = _dbContext.ListSong.Where(x => x.PlaylistId == id); foreach (ListSong ls in couples) { var song = _dbContext.Song.Where(x => x.Id == ls.SongId).FirstOrDefault(); songs.Add(SongMapper.FromDatabase(song)); } return(songs); }
public SongModel GetById(string id) { var song = _songRepository.GetById(id); if (song == null) { throw new NotFoundException(Messages.InvalidSongId); } var songModel = SongMapper.ToSongModel(song); return(songModel); }
public void Add(AddUpdateSongModel addSongModel) { if (string.IsNullOrEmpty(addSongModel.Name)) { throw new ValidationException(Messages.SongNameRequired); } if (string.IsNullOrEmpty(addSongModel.Url)) { throw new ValidationException(Messages.SongUrlRequired); } if (string.IsNullOrEmpty(addSongModel.SongCategoryId)) { throw new ValidationException(Messages.SongCategoryIdRequired); } if (string.IsNullOrEmpty(addSongModel.ArtistId)) { throw new ValidationException(Messages.SongArtistIdRequired); } var songCategory = _songCategoryRepository.GetById(addSongModel.SongCategoryId); if (songCategory == null) { throw new NotFoundException(Messages.InvalidSongCategoryId); } var artist = _artistRepository.GetById(addSongModel.ArtistId); if (artist == null) { throw new NotFoundException(Messages.InvalidArtistId); } var song = SongMapper.ToSong(addSongModel); song.Id = SecurityUtils.GenerateEntityId(); _songRepository.Add(song); }
public async Task <Models.Song> GetAsync(int id) { var result = await _dbContext.Song.SingleOrDefaultAsync(x => x.Id == id); return(SongMapper.FromDatabase(result)); }
public IEnumerable <Models.Song> GetAll() { return(_dbContext.Song.Select(x => SongMapper.FromDatabase(x))); }
public OperationMaster() { mapper = new GenreMapper(); songmmp = new SongMapper(); dao = SqlDao.GetInstance(); }