Beispiel #1
0
        public bool Edit(EditSongDto editInfo)
        {
            try
            {
                var song = this.context.Songs.Find(editInfo.Id);
                if (song == null)
                {
                    return(false);
                }

                song.Name           = editInfo.Name;
                song.Genre          = editInfo.Genre;
                song.ReleaseDate    = editInfo.ReleaseDate;
                song.ReleaseStage   = editInfo.ReleaseStage;
                song.TrackNumber    = editInfo.TrackNumber;
                song.MusicVideoLink = editInfo.MusicVideoLink;
                song.Lyrics         = editInfo.Lyrics;
                song.ApprovalStatus = ApprovalStatus.Pending;
                song.AlbumsSongs.Clear();

                this.context.Songs.Update(song);
                this.context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #2
0
        private void SetDefaultValues(EditSongDto dto)
        {
            txb_songname.Text  = dto.Name;
            txb_bytes.Text     = dto.Bytes.ToString();
            txb_composer.Text  = dto.Composer;
            txb_milisec.Text   = dto.Miliseconds.ToString();
            txb_unitprice.Text = dto.Price.ToString();

            cbx_album.SelectedIndex     = dto.AlbumId; //might be wrong
            cbx_genre.SelectedIndex     = dto.GenreId; //might be wrong
            cbx_mediaType.SelectedIndex = dto.MediaId; //might be wrong
        }
Beispiel #3
0
        public Form2(int id)
        {
            InitializeComponent();
            PopulateDropDown(GetMediaType(), cbx_mediaType);
            PopulateDropDown(GetAlbum(), cbx_album);
            PopulateDropDown(GetGenre(), cbx_genre);
            PopulatePlaylist();

            this.id = id;
            EditSongDto currentSongDto = GetSongById().First() as EditSongDto;

            SetDefaultValues(currentSongDto);

            btn_updatesongf2.Visible = true;
        }
        public void Edit_ChangesProperties()
        {
            // Arrange
            var context = this.ServiceProvider.GetRequiredService <WmipDbContext>();
            var song    = new Song {
                Id = 1, Name = "songs1"
            };

            context.Songs.Add(song);
            context.SaveChanges();
            var songsService = new SongsService(context);
            var editInfo     = new EditSongDto()
            {
                Id = 1, Name = "sssoong"
            };

            // Act
            songsService.Edit(editInfo);

            //Assert
            Assert.Equal(editInfo.Name, context.Songs.First().Name);
        }