Example #1
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            if (TrackNameTxtBox.Text == string.Empty)
            {
                TrackNameTxtBox.BackColor = Color.IndianRed;
                return;
            }

            if (TrackAuthorTxtBox.Text == string.Empty)
            {
                TrackAuthorTxtBox.BackColor = Color.IndianRed;
                return;
            }

            if (GenreCmbBox.Text == string.Empty)
            {
                GenreCmbBox.BackColor = Color.IndianRed;
                return;
            }

            _musicTrack.TrackName   = TrackNameTxtBox.Text;
            _musicTrack.TrackAuthor = TrackAuthorTxtBox.Text;
            _musicTrack.GenreId     = GenresRepo.GetByName(GenreCmbBox.Text).GenreId;
            if (PlaylistCmbBox.Text != string.Empty)
            {
                var playlist = PlaylistsRepo.GetById((int)PlaylistCmbBox.SelectedValue);
                playlist.MusicTracks.Add(_musicTrack);
                PlaylistsRepo.AddOrUpdate(playlist);
            }

            MusicTracksRepo.AddOrUpdate(_musicTrack);

            Close();
        }
        private void редактироватьТрекToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var selectedRow = TracksGridView.SelectedRows[0];

            var musicTrackDto = (MusicTrackDto)selectedRow.DataBoundItem;

            var genre = GenresRepo.GetByName(musicTrackDto.GenreName);

            var musicTrack = new MusicTrack
            {
                TrackAuthor  = musicTrackDto.AuthorName,
                TrackName    = musicTrackDto.Name,
                TrackId      = musicTrackDto.Id,
                UploadUserId = _currentUser.UserId,
                GenreId      = genre.GenreId,
                Genres       = genre
            };

            new MusicTrackForm(musicTrack).Show(this);

            FillOrRefreshTracksGridView();
        }