private async Task CreatePlaylist()
        {
            List <Song> songsList = new List <Song>();

            foreach (SongViewModel songViewModel in SelectedSongs)
            {
                Song song = await songRepository.GetSong(songViewModel.Id);

                songsList.Add(song);
            }
            string playlistName = await _pageService.DisplayEntry(AppResources.DisplayEntry_EnterPlaylistName, "");

            if (String.IsNullOrEmpty(playlistName))
            {
                await _pageService.DisplayAlert(AppResources.AlertDialog_Error, AppResources.AlertDialog_NameCannotBeEmpty, AppResources.AlertDialog_OK);
            }
            else
            {
                Playlist playlist = new Playlist()
                {
                    Name             = playlistName,
                    Songs            = songsList,
                    CustomSongsOrder = false
                };
                await playlistRepository.AddPlaylist(playlist);

                await _pageService.DisplayAlert(AppResources.AlertDialog_Success, AppResources.AlertDialog_PlaylistCreated, AppResources.AlertDialog_OK);

                UnCheckAllSongs();
                SetCheckBoxVisibility(false);
                ShowChooseOption = false;
            }
        }
Пример #2
0
        public void TestCreerCustomerAndPlaylist()
        {
            Customer customer = new Customer()
            {
                Address    = "Villejean",
                Country    = "France",
                Email      = "*****@*****.**",
                Fax        = "blabla",
                PostalCode = "35000",
                Phone      = "xxx",
                City       = "Rennes",
                FirstName  = "Kai",
                LastName   = "Lenny"
            };

            using (var trans = _ChinookEntities.Database.BeginTransaction())
            {
                _CustomerRepo.Add(customer);

                List <Track> listTracks = _TrackRepo.GetTrackByComposer("AC/DC");

                Playlist playlist = new Playlist()
                {
                    Name = "Par défaut", Track = listTracks
                };

                _PlayListRepo.AddPlaylist(playlist);

                _ChinookEntities.SaveChanges();

                trans.Commit();
            }
        }
        private async Task RestoreBackup()
        {
            try
            {
                var options = new PickOptions
                {
                    PickerTitle = "Please select a json file",
                };

                var result = await FilePicker.PickAsync(options);

                if (result != null)
                {
                    Stream stream = await result.OpenReadAsync();

                    StreamReader streamReader = new StreamReader(stream);
                    string       json         = streamReader.ReadToEnd();
                    var          db           = JsonConvert.DeserializeObject <DatabaseModel>(json);

                    foreach (var item in db.Playlists)
                    {
                        playlistRepository.AddPlaylist(item);
                    }
                    foreach (var item in db.Positions)
                    {
                        positionRepository.AddPosition(item);
                    }
                    foreach (var item in db.SongPlaylists)
                    {
                        songPlaylistRepository.AddSongPlaylistRelation(item);
                    }
                    foreach (var item in db.SongPositions)
                    {
                        songPositionRepository.AddSongPositionRelation(item);
                    }
                    foreach (var item in db.Songs)
                    {
                        songRepository.AddSong(item);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #4
0
        public void AddPlaylist()
        {
            string title  = "Super Hero";
            int    userId = 2;


            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                PlaylistRepository playlist = new PlaylistRepository(context);
                var users = playlist.AddPlaylist(title, userId);

                Assert.AreEqual(title, users.Title);
                Assert.AreEqual(userId, users.UserId);

                context.Dispose();
            }
        }
Пример #5
0
 public int AddPlaylist(Playlist p, int gebruikerid)
 {
     return(repo.AddPlaylist(p, gebruikerid));
 }