private async void btnSubmitTrack_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { TrackUpsertRequest request = new TrackUpsertRequest() { AlbumId = hold.AlbumId, TrackName = txtTrackName.Text, TrackLyrics = txtLyrics.Text, TrackNumber = int.Parse(txtTrackNumber.Text), TrackViews = hold.TrackViews, TrackYoutubeId = txtYtid.Text }; if (_trackId.HasValue) { await _trackService.Update <Model.Track>(_trackId, request); } else { request.TrackViews = 0; await _trackService.Insert <Model.Track>(request); SetPropertiesNull(); } refreshHandler?.Invoke(this, null); MessageBox.Show("Task successful"); } }
private async void btnSave_Click(object sender, EventArgs e) { axWindowsMediaPlayer1.Ctlcontrols.stop(); byte[] MP3File = File.ReadAllBytes(axWindowsMediaPlayer1.URL); var trackGenres = Convert.ToInt32(cbGenres.SelectedValue); int trackArtist = Convert.ToInt32(cbArtist.SelectedValue); var request = new TrackUpsertRequest() { Name = txtName.Text, Length = txtLength.Text, MP3File = MP3File, GenreID = trackGenres, ArtistID = trackArtist }; await trackService.Insert <MTrack>(request); MessageBox.Show("Track added successfully", "Success", MessageBoxButtons.OK); PanelHelper.SwapPanels(this.Parent, this, new TrackList()); }
private async void btnSave_Click(object sender, EventArgs e) { if (ValidateChildren()) { MediaPlayer.Ctlcontrols.stop(); var trackGenres = lbGenres.Items.Cast <Model.Genre>().Select(i => i.ID).ToList(); var trackArtists = lbFeaturedArtists.Items.Cast <Model.Artist>().Select(i => i.ID).ToList(); int mainArtist = Convert.ToInt32(cbMainArtist.SelectedValue); byte[] MP3File = File.ReadAllBytes(MediaPlayer.URL); var request = new TrackUpsertRequest() { Name = Convert.ToString(txtName.Text), Length = Convert.ToString(txtLength.Text), Genres = trackGenres, MainArtist = mainArtist, FeaturedArtists = trackArtists, MP3File = MP3File }; if (_ID.HasValue) { var genresToDelete = _track.TrackGenres .Where(i => !trackGenres.Any(j => j.Equals(i.GenreID))) .Select(i => i.GenreID) .ToList(); var artistToDelete = _track.TrackArtists .Where(i => !trackArtists.Any(j => j.Equals(i.ArtistID))) .Select(i => i.ArtistID) .ToList(); var oldMainArtist = _track.TrackArtists .Where(i => i.TrackArtistRole == "Main") .Select(i => i.ArtistID) .SingleOrDefault(); if (oldMainArtist != mainArtist) { artistToDelete.Add(oldMainArtist); } request.GenresToDelete = genresToDelete; request.ArtistsToDelete = artistToDelete; await _trackApiService.Update <Model.Track>(_ID.Value, request); } else { await _trackApiService.Insert <Model.Track>(request); PanelHelper.SwapPanels(this.Parent, this, new ucTrackUpsert()); } MessageBox.Show("Success", "Success", MessageBoxButtons.OK); } }