public async void Edit(string accessToken, string artist, string title, string lyrics, SongGenres songGenre, bool?isVisible) { if (accessToken == null) { throw new NullReferenceException("Access token should not be null"); } var xDoc = await Task.Run(() => XDocument.Load( $"https://api.vk.com/method/audio.edit.xml?" + $"owner_id={OwnerId}&" + $"audio_id={Id}&" + $"artist={artist}&" + $"title={title}&" + $"text={lyrics}&" + $"genre_id={(int)songGenre}&" + $"no_search={Convert.ToInt32(isVisible)}&" + $"access_token={accessToken}")); var xElement = xDoc.Root.Element("error_code"); if (xElement != null) { MessageBox.Show(((VkErrors)(Convert.ToInt32(xElement.Value))).ToString()); return; } System.Windows.MessageBox.Show(xDoc.ToString()); Artist = artist; Title = title; _vkLyrics = lyrics; Genre = songGenre; LyricsId = xDoc.Root.Value; _isSuggestedLyricsLoaded = false; _isVkLyricsLoaded = false; OnPropertyChanged(null); }
public void UpdateSongGenre(int id, SongGenre updatedSongGenre) { var songGenre = SongGenres.SingleOrDefault(x => x.Id == id); if (songGenre != null) { songGenre.Name = updatedSongGenre.Name; } this.SaveChanges(); }
public void DeleteSongGenre(int id) { var songGenre = SongGenres.SingleOrDefault(x => x.Id == id); if (songGenre != null) { SongGenres.Remove(songGenre); } this.SaveChanges(); }
public Song(string id, string ownerId, string artist, string title, string duration, string url, string lyricsId, string genreId) { Id = id; OwnerId = ownerId; Artist = artist; Title = title; Duration = TimeSpan.FromSeconds(Convert.ToUInt32(duration)); Url = url; LyricsId = lyricsId; if (genreId != null) { Genre = (SongGenres)Enum.Parse(typeof(SongGenres), genreId); } else { Genre = SongGenres.Other; } }
public Artist(string name, SongGenres genre) { this.Name = name; this.Genre = genre; }
public SongGenre InsertSongGenre(SongGenre songGenre) { SongGenres.Add(songGenre); this.SaveChanges(); return(songGenre); }
//-------------------// // SongGenre methods // //-------------------// public SongGenre GetSongGenre(int id) { return(SongGenres.FirstOrDefault(x => x.Id == id)); }