Пример #1
0
 // Changes current view to the EditSong view when the user selects the Edit Button
 public ActionResult EditSong(int id)
 {
     using (var repo = new SongRepository())
     {
         return(View("EditSong", repo.GetSong(id)));
     }
 }
Пример #2
0
 // Returns the SongList view and shows the list of songs saved in the SongRepository
 public ActionResult YourSongs()
 {
     using (var repo = new SongRepository())
     {
         return(View("SongList", repo.Songs.ToList()));
     }
 }
Пример #3
0
        public string Get(int id)
        {
            SongRepository repo = new SongRepository();
            Song           song = repo.GetSong(id);

            return(JsonConvert.SerializeObject(song));
        }
        /// <summary>
        /// Gets the SongRepository singleton instance. SongRepository is endpoint for all song related queries
        /// </summary>
        /// <returns></returns>
        public SongRepository GetSongRepositoryInstance()
        {
            SongRepository sr = SongRepository.Instance;

            sr.SetAuthToken(_authToken);
            return(sr);
        }
Пример #5
0
        public EditPlaylistViewModel(Playlist playlist, User user)
        {
            Playlist = playlist;
            User     = user;

            _songRepo     = new SongRepository();
            _artRepo      = new ArtRepository();
            _playlistRepo = new PlaylistRepository();
            _playlistRepo.Dispose();

            Art              = new ObservableCollection <string>(_artRepo.GetPlaylistArt());
            AllSongs         = new ObservableCollection <Song>(_songRepo.GetAllSongs());
            PlaceholderSongs = CurrentSongs;

            Title          = Playlist.Title;
            Image          = Playlist.Image;
            PlaylistUserID = Playlist.UserID;
            SelectedImage  = Playlist.Image;

            // COMMANDS
            AddSongToPlaylistCommand      = new RelayCommand(new Action <object>(AddSongToPlaylist));
            RemoveSongFromPlaylistCommand = new RelayCommand(new Action <object>(RemoveSongFromPlaylist));
            CloseEditPlaylistViewCommand  = new RelayCommand(new Action <object>(CloseEditPlaylistView));
            SavePlaylistChangesCommand    = new RelayCommand(new Action <object>(SavePlaylistChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
        }
        protected override void BeforeDelete(PlayList item, bool all)
        {
            if (all == true)
            {
                SongRepository songRepo = new SongRepository();
                songRepo.GetAll(x => x.ParentID == item.Id).ForEach(x => songRepo.Delete(x));
            }
            SqlConnection conn = new SqlConnection(connectionString);

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = String.Format("DELETE FROM [UserToPlayList] WHERE  [PlayListId] = @PlayListId");
            //cmd.Parameters.AddWithValue("UserId", user.Id);
            cmd.Parameters.AddWithValue("PlayListId", item.Id);

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
            //}
        }
Пример #7
0
 public UploadController(
     SongRepository songRepository,
     TagRepository tagRepository)
 {
     _songRepository = songRepository;
     _tagRepository  = tagRepository;
 }
Пример #8
0
        public IEnumerable <Song> GetByAlbum(int id)

        {
            SongRepository songRepoFix = songRepo as SongRepository;

            return(songRepoFix.GetByAlbumID(id));
        }
Пример #9
0
        public EditPlaylistViewModel(Playlist playlist, User user)
        {
            Playlist = playlist;
            User = user;

            _songRepo = new SongRepository();
            _artRepo = new ArtRepository();
            _playlistRepo = new PlaylistRepository();
            _playlistRepo.Dispose();

            Art = new ObservableCollection<string>(_artRepo.GetPlaylistArt());
            AllSongs = new ObservableCollection<Song>(_songRepo.GetAllSongs());
            PlaceholderSongs = CurrentSongs;

            Title = Playlist.Title;
            Image = Playlist.Image;
            PlaylistUserID = Playlist.UserID;
            SelectedImage = Playlist.Image;

            // COMMANDS
            AddSongToPlaylistCommand = new RelayCommand(new Action<object>(AddSongToPlaylist));
            RemoveSongFromPlaylistCommand = new RelayCommand(new Action<object>(RemoveSongFromPlaylist));
            CloseEditPlaylistViewCommand = new RelayCommand(new Action<object>(CloseEditPlaylistView));
            SavePlaylistChangesCommand = new RelayCommand(new Action<object>(SavePlaylistChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            });
        }
Пример #10
0
        public IActionResult SadIndex()
        {
            var repo = new SongRepository();

            repo.SortSong();
            return(View(repo.sadSongs));
        }
        protected override void BeforeView(PlayList item, ref bool cancel)
        {
            cancel = true;

            if (item.ParentId != AuthenticationService.LoggedUser.Id && (item.IsPublic == true || item.Shares.FindAll(u => u.Id == AuthenticationService.LoggedUser.Id).Count > 0))
            {
                SongRepository repo = new SongRepository();
                foreach (Song song in repo.GetAll(x => x.ParentID == item.Id))
                {
                    Console.WriteLine("Title: " + song.Title);
                    Console.WriteLine("Artist: " + song.Artist);
                    Console.WriteLine("Year: " + song.Year);
                    Console.WriteLine("###############################");
                }
            }

            if (item.ParentId == AuthenticationService.LoggedUser.Id)
            {
                SongManagementView songManagementView = new SongManagementView(item);
                songManagementView.Show();

                return;
            }

            Console.ReadKey(true);
        }
Пример #12
0
        public IActionResult PeacefulIndex()
        {
            var repo = new SongRepository();

            repo.SortSong();
            return(View(repo.peacefulSongs));
        }
Пример #13
0
        public void DeleteSongsWithBadGenre()
        {
            string         filter         = "PartitionKey eq 'Other'";
            SongRepository songRepository = new SongRepository(new Repository("log"));

            songRepository.Process(filter, songRepository.Delete, null);
        }
        public CheckController(IOptions <AppSettings> options, Bot bot, SongRepository songRepository)
        {
            var appsetings = options.Value;

            _bot            = bot.Get();
            _songRepository = songRepository;
        }
Пример #15
0
        public void PopulateSongTable()
        {
            var gDriveServiceContainer = new GDriveService();
            var gdriveService          = gDriveServiceContainer.GetService();
            var songRepository         = new SongRepository(new Repository("log"));

            FilesResource.ListRequest request = gdriveService.Files.List();
            var fileList = new List <File>();

            try
            {
                FileList files = request.Execute();
                fileList.AddRange(files.Items);
                request.PageToken = files.NextPageToken;
                foreach (var file in fileList)
                {
                    try
                    {
                        songRepository.Set(file.Id, file.DownloadUrl);
                    }
                    catch (Exception ex1)
                    {
                        testContextInstance.WriteLine("Error: {0}", ex1.Message);
                    }
                }
            }
            catch (Exception e)
            {
                testContextInstance.WriteLine("Error: {0}", e.Message);
            }
        }
Пример #16
0
        public void Populate()
        {
            genreRepository.DeleteAll();

            var songRepository = new SongRepository(new Repository("log"));
            Dictionary <string, int> genres = songRepository.ProcessGenres(SaveGenres);
        }
Пример #17
0
 public PlayerController(
     SongRepository songRepository,
     TagRepository tagRepository)
 {
     _songRepository = songRepository;
     _tagRepository  = tagRepository;
 }
Пример #18
0
        /// <summary>
        /// Makes it possible to access SongLogic in the Console
        /// </summary>
        /// <returns>Returns a SongLogic instance</returns>
        public static SongLogic CreateRealLogic()
        {
            StreamingDatabaseEntities se = new StreamingDatabaseEntities();
            SongRepository            sr = new SongRepository(se);

            return(new SongLogic(sr));
        }
        public SongListViewModel()
        {
            songRepository     = new SongRepository(DependencyService.Get <ISQLiteDb>());
            _pageService       = new PageService();
            playlistRepository = new PlaylistRepository(DependencyService.Get <ISQLiteDb>());

            LoadSongsCommand             = new Command(async() => await LoadSongs());
            SelectSongCommand            = new Command <SongViewModel>(async song => await SelectSong(song));
            CreatePlaylistCommand        = new Command(async() => await CreatePlaylist());
            AddToPlaylistCommand         = new Command <SongViewModel>(song => AddToPlaylist(song));
            DeleteFromPlaylistCommand    = new Command <SongViewModel>(song => DeleteFromPlaylist(song));
            StartSongPresentationCommand = new Command <int>(async id => await StartPresentation(id));

            MessagingCenter.Subscribe <SongAddAndDetailViewModel, Song>
                (this, Events.SongAdded, OnSongAdded);

            MessagingCenter.Subscribe <SongAddAndDetailViewModel, Song>
                (this, Events.SongUpdated, OnSongUpdated);

            MessagingCenter.Subscribe <SongAddAndDetailViewModel, Song>
                (this, Events.SongDeleted, OnSongDeleted);


            LoadSongsCommand.Execute(null);
            SetCheckBoxVisibility(false);
        }
Пример #20
0
        public EditSongViewModel(Song song)
        {
            Song         = song;
            Title        = Song.Title;
            Artist       = Song.Artist;
            Duration     = Song.Duration;
            Art          = Song.Image;
            SelectedArt  = Song.Image;
            _artRepo     = new ArtRepository();
            ArtSelection = new ObservableCollection <string>(_artRepo.GetAlbumArt());
            _songRepo    = new SongRepository();

            CloseEditSongViewCommand = new RelayCommand(new Action <object>(CloseEditSongView));
            SaveChangesToSongCommand = new RelayCommand(new Action <object>(SaveChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title) &&
                    TitleRule.TitleRegex.IsMatch(Artist) &&
                    DurationRule.DurationRegex.IsMatch(Duration))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
        }
Пример #21
0
 public TopSongController(
     SongRepository repository,
     IMapper mapper, IUrlHelper urlHelper, IPropertyMappingContainer propertyMappingContainer, ITypeHelperService typeHelperService) : base(urlHelper, propertyMappingContainer, typeHelperService)
 {
     _repository = repository;
     _mapper     = mapper;
 }
Пример #22
0
        public void GetAllQueryable_Update_GetById()
        {
            using (var ctx = new eJukeboxContext())
            {
                var repo   = new SongRepository(ctx);
                var table  = repo.Table();
                var entity = table.FirstOrDefault(x => x.Title.Contains("the"));
                var result = entity.ToDomain();
                //var result = repo.Table().FirstOrDefault(x => x.Title.Contains("the")).ToDomain();
                //var result = ctx.Song.FirstOrDefault(x => x.Title.Contains("the")).ToDomain();

                if (result != null)
                {
                    var originalTitle = result.Title;

                    //Save a test change
                    result.Title = result.Title + "-test";
                    repo.Update(result);

                    //Reread the record from the db. Should include change.
                    var result2 = repo.Get(result.Id);
                    Assert.IsTrue(result2.Title == result.Title);

                    //Restore original value
                    result2.Title = originalTitle;
                    repo.Update(result2);
                }
                else
                {
                    Assert.Inconclusive("Can't find record to test with.");
                }
            }
        }
Пример #23
0
        public string Delete(int id)
        {
            SongRepository repo   = new SongRepository();
            int            result = repo.DeleteSong(id);

            return($"{{\"result\":{result}}}");
        }
Пример #24
0
        public IActionResult AngryIndex()
        {
            var repo = new SongRepository();

            repo.SortSong();
            return(View(repo.angrySongs));
        }
Пример #25
0
        public EditSongViewModel(Song song)
        {
            Song = song;
            Title = Song.Title;
            Artist = Song.Artist;
            Duration = Song.Duration;
            Art = Song.Image;
            SelectedArt = Song.Image;
            _artRepo = new ArtRepository();
            ArtSelection = new ObservableCollection<string>(_artRepo.GetAlbumArt());
            _songRepo = new SongRepository();

            CloseEditSongViewCommand = new RelayCommand(new Action<object>(CloseEditSongView));
            SaveChangesToSongCommand = new RelayCommand(new Action<object>(SaveChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title) &&
                    TitleRule.TitleRegex.IsMatch(Artist) &&
                    DurationRule.DurationRegex.IsMatch(Duration))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            });
        }
        public SongRepositoryTests()
        {
            db = new MusicContext();
            db.Database.BeginTransaction();

            underTest = new SongRepository(db);
        }
Пример #27
0
 public SongReviewService(SongReviewListQuery songReviewListQuery, SongReviewRepository songReviewRepository,
                          SongRepository songRepository, ClientRepository clientRepository)
 {
     this.songReviewListQuery  = songReviewListQuery;
     this.songReviewRepository = songReviewRepository;
     this.songRepository       = songRepository;
     this.clientRepository     = clientRepository;
 }
 public SonglistService(SonglistRepository songlistRepository, SonglistListQuery songlistListQuery,
                        SongRepository songRepository, PlaylistRepository playlistRepository)
 {
     _songlistRepository = songlistRepository;
     _songlistListQuery  = songlistListQuery;
     _songRepository     = songRepository;
     _playlistRepository = playlistRepository;
 }
Пример #29
0
        public void GetSong()
        {
            string id             = "0B4dXRBkWJRuDME9MWXMtTklpLUk";
            var    songRepository = new SongRepository(new Repository("log"));
            var    song           = songRepository.Get(id);

            Assert.IsNotNull(song);
        }
Пример #30
0
        //public IEnumerable<string> Get()
        public string Get()
        {
            SongRepository repo  = new SongRepository();
            List <Song>    songs = repo.GetSongs();

            return(JsonConvert.SerializeObject(songs));
            //return new string[] { "value1", "value2" };
        }
Пример #31
0
 // Removes songs from the SongList when the user selects the Delete Button
 public ActionResult DeleteSong(Song song)
 {
     using (var repo = new SongRepository())
     {
         repo.DeleteSong(song);
         return(View("SongList", repo.Songs.ToList()));
     }
 }
Пример #32
0
 public SongService(SongRepository songRepository, SongListQuery songListQuery, AlbumRepository albumRepository,
                    SongReviewRepository songReviewRepository)
 {
     _songRepository       = songRepository;
     _songListQuery        = songListQuery;
     _albumRepository      = albumRepository;
     _songReviewRepository = songReviewRepository;
 }
Пример #33
0
        public CreatePlaylistViewModel(User user = null)
        {
            User = user;

            _songRepo = new SongRepository();
            _artRepo = new ArtRepository();
            _songSelection = new ObservableCollection<Song>(_songRepo.GetAllSongs());
            _artSelection = new ObservableCollection<string>(_artRepo.GetPlaylistArt());
            _songRepo.Dispose();

            CreateNewPlaylistCommand = new RelayCommand(new Action<object>(CreatePlaylist), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Name))
                {
                    return true;
                } else
                {
                    return false;
                }
            });

            CloseCreatePlaylistViewCommand = new RelayCommand(new Action<object>(CloseCreatePlaylistView));
        }
Пример #34
0
        public void Save()
        {
            Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase();

            if (_artist.ArtistId == 0)
            {
                //ADD ARTIST
                IRepository<IArtist> artist = new ArtistRepository(db);
                IRepositoryBLL<IArtist> artistRepoBll = new ArtistRepositoryBLL(artist);
                _artist = artistRepoBll.Add(_artist);

                //ADD ARTIST CONTACT
                IRepository<IArtistContact> contact1 = new ArtistContactRepository(db);
                IRepositoryBLL<IArtistContact> contactBll = new ArtistContactRepositoryBLL(contact1);
                _artistContact.ArtistId = _artist.ArtistId;
                _artistContact = contactBll.Add(_artistContact);

                //ADD DISCOGRAPHY
                IRepository<IDiscography> disco = new DiscographyRepository(db);
                IRepositoryBLL<IDiscography> discoBll = new DiscographyRepositoryBLL(disco);
                _discography.ArtistId = _artist.ArtistId;
                _discography = discoBll.Add(_discography);
            }

            if (_album.AlbumId == 0)
            {
                //ADD ALBUM
                IRepository<IAlbum> album1 = new AlbumRepository(db);
                IRepositoryBLL<IAlbum> albumBll = new AlbumRepositoryBLL(album1);
                _album.ArtistId = _artist.ArtistId;
                _album = albumBll.Add(_album);
            }

            //ADD SONGS
            IRepository<ISong> song1 = new SongRepository(db);
            IRepositoryBLL<ISong> songBll = new SongRepositoryBLL(song1);
            foreach (Song item in _songs)
            {
                item.AlbumId = _album.AlbumId;
                songBll.Add(item);
            }
        }
 public void Initialize()
 {
     Repository = new SongRepository();
 }
Пример #36
0
 public MusicService(SongRepository songRepository, Repository<MediaFile> mediaFileRepository)
 {
     SongRepository = songRepository;
     MediaFileRepository = mediaFileRepository;
 }
Пример #37
0
        public MainViewModel()
        {
            _viewModels = new ObservableCollection<ViewModelBase>();
            _playlistRepository = new PlaylistRepository();
            _songRepository = new SongRepository();
            _userRepo = new UserRepository();
            _playlistListViewModel = new PlaylistListViewModel(_playlistRepository);
            _songListViewModel = new SongListViewModel(_songRepository);
            _songViewModel = new SongViewModel();
            _menuViewModel = new MenuViewModel();

            _viewModels.Add(_playlistListViewModel);
            _viewModels.Add(_songListViewModel);
            _viewModels.Add(_songViewModel);
            _viewModels.Add(_menuViewModel);

            #region Registering for ViewModel Commands
            // Listens for a click in menuViewModel
            Messenger.Default.Register<bool>(this, SetCreatePlaylistViewModel, "CreatePlaylistView");
            Messenger.Default.Register<bool>(this, CloseCreatePlaylistView, "CloseCreatePlaylistView");

            // Listens for click in menuViewModel
            Messenger.Default.Register<bool>(this, SetLoginViewModel, "CreateLoginView");
            // Listens for LoginUserViewModel to send this message
            Messenger.Default.Register<bool>(this, CloseLoginViewModel, "CloseLoginView");
            // Listens for menuViewModel logout button click
            Messenger.Default.Register<bool>(this, LogoutUser, "LogoutUser");

            // Listens for register button click in MenuViewModel
            Messenger.Default.Register<bool>(this, SetRegisterViewModel, "CreateRegisterView");
            Messenger.Default.Register<bool>(this, CloseRegisterViewModel, "CloseRegisterView");

            // Listens for menuviewModel AddNewSong button click
            Messenger.Default.Register<bool>(this, SetAddNewSongViewModel, "CreateAddNewSongView");
            Messenger.Default.Register<bool>(this, CloseAddNewSongViewModel, "CloseAddNewSongView");

            // Listenes for menuviewModel EditPlaylist button click
            Messenger.Default.Register<Playlist>(this, SetEditPlaylistViewModel, "CreateEditPlaylistView");
            Messenger.Default.Register<bool>(this, CloseEditPlaylistView, "CloseEditPlaylistView");

            // listens for menuviewmodel Edit Song button click
            Messenger.Default.Register<Song>(this, SetEditSongViewModel, "CreateEditSongView");
            Messenger.Default.Register<bool>(this, CloseEditSongView, "CloseEditSongView");

            // Listenes for menuvireModel Credits button
            Messenger.Default.Register<bool>(this, SetCreditTransactionViewModel, "CreateCreditTransactionView");
            Messenger.Default.Register<bool>(this, CloseCreditTransactionView, "CloseCreditTransactionView");

            // Listens for LoginViewModel successful login, or a RegisterViewModel sucessful registration
            Messenger.Default.Register<User>(this, LoginUser, "UserLogin");

            // Listens for when song is selected, changed, etc
            Messenger.Default.Register<bool>(this, UserPlayedSong, "UserCreditCheck");

            // Listens from MenuViewModel for delete commands
            Messenger.Default.Register<Playlist>(this, DeletePlaylist, "DeletePlaylist");
            Messenger.Default.Register<Song>(this, DeleteSong, "DeleteSong"); 
            #endregion

            User = new User();
        }
 public SongController()
 {
     this.context = new SongRepository(new MusicSystemDbContext());
 }