Ejemplo n.º 1
0
        public ActionResult Select(string name)
        {
            MusicViewModel mv = new MusicViewModel();

            mv.UserName = name;
            return(View("Index", name));
        }
Ejemplo n.º 2
0
 public static void PlayPauseButtonAction(object parameter)
 {
     if (MusicViewModel.GetInstance().IsPlaying == false)        // if player stopped or paused
     {
         var currentlySelectedSong = MusicViewModel.GetInstance().CurrentlySelectedSong;
         var currentlyPlayedSong   = MusicViewModel.GetInstance().CurrentlyPlayedSong;
         if (currentlyPlayedSong != null)
         {
             if (currentlySelectedSong.Path.Equals(currentlyPlayedSong.Path) == false)
             {
                 PlayAudioFile(currentlySelectedSong.Path);
                 MusicViewModel.GetInstance().CurrentlyPlayedSong = currentlySelectedSong;
                 songIndex = MusicViewModel.GetInstance().FilteredSongs.IndexOf(currentlySelectedSong);
             }
             else
             {
                 ResumeAudioFile();
             }
         }
         else
         {
             PlayAudioFile(currentlySelectedSong.Path);
             MusicViewModel.GetInstance().CurrentlyPlayedSong = currentlySelectedSong;
             songIndex = MusicViewModel.GetInstance().FilteredSongs.IndexOf(currentlySelectedSong);
         }
     }
     else
     {
         PauseAudioFile();
     }
 }
Ejemplo n.º 3
0
        public static void AddEmptyPlaylist(string name)
        {
            Playlist newPlaylist = new Playlist(name);

            MusicViewModel.GetInstance().Playlists.Add(newPlaylist);
            MusicViewModel.GetInstance().PlaylistsNames.Add(newPlaylist.Name);
        }
Ejemplo n.º 4
0
        //[Route("/Music/Index")]
        public ActionResult Index(string id, string artist, string track, string genre)
        {
            System.Console.WriteLine("artist = {0}", artist);
            System.Console.WriteLine("låt = {0}", track);
            _holder = new DataHolder();
            var search = new SearchItems()
            {
                artist = artist, track = track, genre = genre
            };

            var viewModel = new MusicViewModel
            {
                SearchItems = search,
                DataHolder  = _holder,
                artist      = artist,
                track       = track,
                genre       = genre,
                id          = id
            };

            viewModel.artist = artist;
            viewModel.track  = track;
            viewModel.genre  = genre;
            test.search(viewModel);
            return(View(viewModel));
        }
Ejemplo n.º 5
0
        public void Execute(object parameter)
        {
            _musicViewModel = (MusicViewModel) parameter;
            _musicViewModel.Busy = true;

            CopyMusicAsync(_musicViewModel.MusicDestination);
        }
Ejemplo n.º 6
0
        public async Task <List <MusicView> > GetAll(string keyword)
        {
            var _music = from m in _context.musics
                         select m;

            if (!string.IsNullOrEmpty(keyword))
            {
                _music = _music.Where(x => x.Name.Contains(keyword));
            }

            var category = from a in _music
                           join b in _context.Categories on a.CategoriesId equals b.Id
                           select new MusicView
            {
                Name       = a.Name,
                Categories = b.CateName,
                Single     = a.Single,
                Year       = a.Year
            };
            var temp1 = new MusicViewModel
            {
                Musics = await category.ToListAsync()
            };

            return(await category.ToListAsync());
        }
Ejemplo n.º 7
0
 private MainViewModel()
 {
     SelectedTabIndex   = 0;
     SettingsViewModel  = SettingsViewModel.GetInstance();
     MusicViewModel     = MusicViewModel.GetInstance();
     DiscoveryViewModel = DiscoveryViewModel.GetInstance();
 }
Ejemplo n.º 8
0
        public async Task <IActionResult> AddMusic(MusicViewModel musicModelView)
        {
            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    var music = new Music()
                    {
                        ArtistId = int.Parse(musicModelView.AristId), Name = musicModelView.Music.Name
                    };

                    //Get token
                    var JWToken = HttpContext.Session.GetString("token");
                    if (string.IsNullOrEmpty(JWToken))
                    {
                        ViewBag.MessageError = "You must be authenticate";
                        return(View(musicModelView));
                    }
                    string stringData  = JsonConvert.SerializeObject(music);
                    var    contentData = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", JWToken);
                    var response = await client.PostAsync(URLBase + "Music", contentData);

                    var result = response.IsSuccessStatusCode;
                    if (result)
                    {
                        return(RedirectToAction("Index"));
                    }
                    ViewBag.MessageError = response.ReasonPhrase;
                    return(View(musicModelView));
                }
            }
            return(View(musicModelView));
        }
Ejemplo n.º 9
0
        public ActionResult Index()
        {
            MusicWebAPIController musicWebApiController = new MusicWebAPIController();
            MusicViewModel        musicViewModel        = musicWebApiController.Get();

            return(View(musicViewModel));
        }
Ejemplo n.º 10
0
        public ActionResult FilterMusics([FromUri] IEnumerable <int> genreIDs, int?composerID, int?castID, int?albumID, int?performerID)
        {
            MusicWebAPIController musicWebApiController = new MusicWebAPIController();
            MusicViewModel        musicViewModel        = musicWebApiController.FilterMusics(genreIDs, composerID, castID, albumID, performerID);

            return(Json(musicViewModel, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        private void MenuItemRemoveGoToDirectory_Click(object sender, RoutedEventArgs e)
        {
            var fullPath  = MusicViewModel.GetInstance().CurrentlySelectedSong.Path;
            var directory = Path.GetDirectoryName(fullPath);

            Process.Start("explorer.exe", directory);
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> AddMusic(MusicViewModel musicViewModel)
        {
            if (ModelState.IsValid)
            {
                // Send data to API with a string content
                using (var client = new HttpClient())
                {
                    var music = new Music()
                    {
                        IdArtist = int.Parse(musicViewModel.IdArtist), Name = musicViewModel.music.Name
                    };
                    // Get the token and check if is not null
                    var jwToken = HttpContext.Session.GetString("token");
                    if (string.IsNullOrEmpty(jwToken))
                    {
                        ViewBag.MessageError = "You Must be authenticate";
                        return(View(musicViewModel));
                    }
                    // if we have a token we add it in header
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", jwToken);

                    string stringData  = JsonConvert.SerializeObject(music);
                    var    contentData = new StringContent(stringData, Encoding.UTF8, "application/json");
                    var    response    = await client.PostAsync(URLBase + "Music", contentData);

                    if (response.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                    ViewBag.MessageError = response.ReasonPhrase;
                }
            }
            return(View(musicViewModel));
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> Album(int albumTypeId, string albumName)
        {
            var album = new Album();

            if (!string.IsNullOrEmpty(albumName))
            {
                album = await _albumRepository.GetByAlbumTypeAsync(albumTypeId, albumName);
            }

            var model = new MusicViewModel();

            if (album != null)
            {
                model.AlbumOldName   = album.Name;
                model.AlbumDescption = album.Description;
                model.AlbumImage     = album.ImageUrl;
                model.AlbumTypeId    = albumTypeId;

                model.Albums = await _albumRepository.GetPageByAlbumTypeAsync(1, 100, albumTypeId);

                model.AlbumTypes = await _albumTypeRepository.GetAllyAsync();
            }
            else
            {
                model.Albums = await _albumRepository.GetAllyAsync();

                model.AlbumTypes = await _albumTypeRepository.GetAllyAsync();
            }

            return(View(model));
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> AlbumType(int bandId, string albumTypeName)
        {
            var albumType = new AlbumType();

            if (!string.IsNullOrEmpty(albumTypeName))
            {
                albumType = await _albumTypeRepository.GetByBandAsync(bandId, albumTypeName);
            }

            var model = new MusicViewModel();

            if (albumType != null)
            {
                model.AlbumTypeOldName   = albumType.Name;
                model.AlbumTypeDescption = albumType.Description;
                model.AlbumTypeImage     = albumType.ImageUrl;
                model.BandId             = bandId;

                model.AlbumTypes = await _albumTypeRepository.GetPageByBandAsync(1, 100, bandId);

                model.Bands = await _bandRepository.GetAllyAsync();
            }
            else
            {
                model.AlbumTypes = await _albumTypeRepository.GetAllyAsync();

                model.Bands = await _bandRepository.GetAllyAsync();
            }

            return(View(model));
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> Band(string bandName)
        {
            var band = new Band();

            if (!string.IsNullOrEmpty(bandName))
            {
                band = await _bandRepository.GetByNameAsync(bandName);
            }

            var model = new MusicViewModel();

            if (band != null)
            {
                model.BandOldName   = band.Name;
                model.BandDescption = band.Description;
                model.BandImage     = band.ImageUrl;

                model.Bands = await _bandRepository.GetAllyAsync();

                model.Genres = await _genreRepository.GetAllyAsync();
            }
            else
            {
                model.Genres = await _genreRepository.GetAllyAsync();

                model.Bands = await _bandRepository.GetAllyAsync();
            }

            return(View(model));
        }
Ejemplo n.º 16
0
        // GET: Musics
        public ActionResult Index(string searchMusicName,
                                  string searchArtistName,
                                  bool?success,
                                  int page = 1,
                                  MusicFieldsSort sortField = MusicFieldsSort.UpdateDate,
                                  bool sortDesc             = true)
        {
            var res = service.GetBySearch(searchMusicName,
                                          searchArtistName,
                                          new PagingRequest(page, 25),
                                          sortField,
                                          sortDesc);

            if (!res.Success)
            {
                return(Json(res.Message, JsonRequestBehavior.AllowGet));
            }
            MusicViewModel viewModel = new MusicViewModel();

            viewModel.Success        = success;
            viewModel.Musics         = res.Entities.Select(msc => new MusicViewModelEntry(msc));
            ViewBag.SearchArtistName = searchArtistName;
            ViewBag.SearchMusicName  = searchMusicName;
            ViewBag.Page             = page;
            ViewBag.TotalPages       = res.TotalPages;
            ViewBag.SortField        = sortField;
            ViewBag.SortDesc         = sortDesc;
            return(View(viewModel));
        }
Ejemplo n.º 17
0
        public void search(MusicViewModel holder)
        {
            Console.WriteLine("Skickar och klockan är {0}", DateTime.Now);
            Console.WriteLine("Låt {0}", holder.track);
            Console.WriteLine("Artist {0}", holder.artist);
            Console.WriteLine("Genre {0}", holder.genre);
            Collector webb = new SpotifyCollector(holder.DataHolder);

            webb.searchTrack(holder.artist, holder.track);

            Console.WriteLine("\n\nTestar lista {0} artister", holder.DataHolder.getArtists().Count);

            Console.WriteLine("{0} kategorier finns", holder.DataHolder.getGenresList().Count);

            foreach (var idName in holder.DataHolder.getIdNameList())
            {
                Console.WriteLine("namn artist: {0} (id={1})\n\n\tRelaterade artister:", idName.name, idName.id);

                webb.getArtistById(idName.id);

                webb.getRelatedArtistsById(idName.id);
                Console.WriteLine("\n\n");
            }

            var list = webb.holder.getIdNameList();

            foreach (var idName in list)
            {
                Console.WriteLine("ID={0}, NAME={1}", idName.id, idName.name);
            }

            Console.WriteLine("Totalt {0} antal relaterade ", webb.holder.getIdNameList().Count);
            Console.WriteLine("{0} kategorier finns", holder.DataHolder.getGenresList().Count);
        }
Ejemplo n.º 18
0
 public static bool CanRemoveSongFromPlaylist(object parameter)
 {
     if (!MusicViewModel.GetInstance().SelectedPlaylistName.Equals("None"))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 19
0
 private void MusicGenresComboBox_OnGotMouseCapture(object sender, MouseEventArgs e)
 {
     if (!MusicViewModel.GetInstance().GenresLoaded)
     {
         GenresManager.InitGenres();
     }
     MusicViewModel.GetInstance().GenresLoaded = true;
 }
Ejemplo n.º 20
0
 public static void LoadPlaylist(Playlist newPlaylist)
 {
     MusicViewModel.GetInstance().Playlists.Add(newPlaylist);
     System.Windows.Application.Current.Dispatcher.BeginInvoke((Action) delegate
     {
         MusicViewModel.GetInstance().PlaylistsNames.Add(newPlaylist.Name);
     });
 }
Ejemplo n.º 21
0
 public static bool CanClickPlayPauseButton(object parameter)    // May cause bug - test it
 {
     if (MusicViewModel.GetInstance().CurrentlySelectedSong != null || waveOutDevice.PlaybackState == PlaybackState.Playing)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 22
0
        public async Task <ActionResult> Genre(MusicViewModel genre)
        {
            var model = new MusicViewModel()
            {
                Genres = await _genreRepository.GetAllyAsync()
            };
            var genreModel = new Genre();

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError(string.Empty, "لطفا مقدار های مناسب پر کنید");
                }
                if (string.IsNullOrEmpty(genre.GenreOldName))
                {
                    genre.GenreOldName = genre.GenreNewName;
                }

                genreModel = await _genreRepository.GetByNameAsync(genre.GenreOldName);

                if (genre.ActionType == "create" || genre.ActionType == "edit")
                {
                    if (genreModel == null)
                    {
                        await _genreRepository.CreateAsync(new Genre
                        {
                            Name = genre.GenreOldName,
                        });

                        model.Genres = await _genreRepository.GetAllyAsync();

                        //return RedirectToAction("Section", new { surveyName = surveys.SurveyTitle });
                        return(View(model));
                    }
                    else
                    {
                        genreModel.Name = (genre.GenreOldName == genre.GenreNewName ? genre.GenreOldName : genre.GenreNewName);

                        await _genreRepository.EditAsync(genreModel.Id, genreModel);
                    }
                }
                else
                {
                    await _genreRepository.DeleteAsync(genreModel.Id);
                }

                model.Genres = await _genreRepository.GetAllyAsync();

                //return RedirectToAction("Section", new { surveyName = model.GenreOldName });
                return(View(model));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model: model));
            }
        }
Ejemplo n.º 23
0
        private void MenuItemAddToPlaylist_OnClick(object sender, RoutedEventArgs e)
        {
            //playlist info
            System.Windows.Controls.MenuItem mi = (MenuItem)e.OriginalSource;
            var playlistName = (string)mi.Header;
            var song         = MusicViewModel.GetInstance().CurrentlySelectedSong;

            PlaylistManager.AddSongToPlaylist(playlistName, song);
        }
Ejemplo n.º 24
0
        public SelectedSongListUc()
        {
            InitializeComponent();

            DataContextChanged += delegate
            {
                MusicViewModel = (MusicViewModel)DataContext;
            };
        }
Ejemplo n.º 25
0
        public void Execute(object parameter)
        {
            _musicViewModel = (MusicViewModel) parameter;
            _musicViewModel.Busy = true;

            SaveModel(_musicViewModel.StorageFileLocation);

            _musicViewModel.Busy = false;
        }
Ejemplo n.º 26
0
        public SingerSearchUc()
        {
            InitializeComponent();

            DataContextChanged += delegate
            {
                MusicViewModel = (MusicViewModel)DataContext;
            };
        }
Ejemplo n.º 27
0
        //public IActionResult CheckMusics(IEnumerable<Music> musics)
        //{
        //    if (musics.Count() == 0)
        //    {
        //        return View("Empty");
        //    }
        //    else
        //    {
        //        return View(musics);
        //    }
        //}
        public IActionResult Create()
        {
            var musicVM = new MusicViewModel()
            {
                Authors = _authorRepository.GetAll()
            };

            return(View(musicVM));
        }
Ejemplo n.º 28
0
        public MusicView()
        {
            InitializeComponent();

            _viewModel       = new MusicViewModel();
            this.DataContext = _viewModel;

            LocalSearchBox.Filter = Filter;
        }
Ejemplo n.º 29
0
        public IActionResult Update(int id)
        {
            var musicVM = new MusicViewModel()
            {
                Music   = _musicRepository.GetByID(id),
                Authors = _authorRepository.GetAll()
            };

            return(View(musicVM));
        }
Ejemplo n.º 30
0
        public static void PreviousSongAction(object parameter)
        {
            var newIndex         = songIndex - 1;
            var nextlyPlayedSong = MusicViewModel.GetInstance().FilteredSongs.ElementAt(newIndex);

            MusicViewModel.GetInstance().CurrentlySelectedSong = nextlyPlayedSong;
            MusicViewModel.GetInstance().CurrentlyPlayedSong   = nextlyPlayedSong;
            songIndex--;
            PlayAudioFile(nextlyPlayedSong.Path);
        }
Ejemplo n.º 31
0
 public IActionResult Create(MusicViewModel musicViewModel)
 {
     if (!ModelState.IsValid)
     {
         musicViewModel.Authors = _authorRepository.GetAll();
         return(View(musicViewModel));
     }
     _musicRepository.Create(musicViewModel.Music);
     return(RedirectToAction("List"));
 }
Ejemplo n.º 32
0
        public static bool CanClickNextSongButton(object parameter)
        {
            var currentlyPlayedSongIndex = songIndex;

            if (currentlyPlayedSongIndex < MusicViewModel.GetInstance().FilteredSongs.Count - 1)
            {
                return(true);
            }
            return(false);
        }