public async Task <IActionResult> Delete(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var song = await _dbContext.Songs.FindAsync(id);

            if (song == null)
            {
                return(NotFound());
            }

            var model = new SongsViewModel()
            {
                Id            = song.Id,
                Name          = song.Name,
                Duration      = FormatDuration(song.DurationSeconds),
                AlbumId       = song.AlbumId,
                PerformerId   = song.PerformerId,
                AlbumName     = (await _dbContext.Albums.FindAsync(song.AlbumId)).Name,
                PerformerName = (await _dbContext.Performers.FindAsync(song.PerformerId)).Name
            };

            return(View(model));
        }
		public SongsViewController ()
		{
			Title = "Songs";
			TableView.Source = new ViewModelDataSource<Song> {
				CellForItem = (tv,item) => {
					var cell = tv.DequeueReusableCell<SongCell>(SongCell.Key);
					cell.Song = item;
					return cell;
				},
				ViewModel = (viewModel = new SongsViewModel()),
			};

			TableView.TableHeaderView = progressView = new UIProgressView (UIProgressViewStyle.Bar) {
				Alpha = 0f
			};

			progressView.SizeToFit ();

			viewModel.ItemsChanged += (sender, e) => 
				InvokeOnMainThread(() => {
					Console.WriteLine("Reloading the TableView.");
					TableView.ReloadData();
				});

			viewModel.SongsUpdated += progress => 
				InvokeOnMainThread(() => {
					Console.WriteLine("{0:P}", progress);
					progressView.Progress = progress;
					progressView.Alpha = progress >= 1f ? 0 : 1;
				});

		}
Exemple #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            SongsViewModel songsViewModel = new SongsViewModel(SongsModel);

            WindowService.Show(songsViewModel);
        }
        public async Task <IActionResult> Index(string searchName = "")
        {
            var allSongs = _dbContext.Songs.ToList();

            allSongs = allSongs.OrderBy(x => x.Name).ToList();

            if (searchName != null && searchName != "")
            {
                allSongs = allSongs.Where(x => x.Name.Contains(searchName)).ToList();
            }

            var model = new SongsAllViewModel()
            {
                Songs = new List <SongsViewModel>()
            };

            foreach (var song in allSongs)
            {
                var singleViewModel = new SongsViewModel()
                {
                    Id            = song.Id,
                    Name          = song.Name,
                    Duration      = FormatDuration(song.DurationSeconds),
                    AlbumId       = song.AlbumId,
                    PerformerId   = song.PerformerId,
                    AlbumName     = (await _dbContext.Albums.FindAsync(song.AlbumId)).Name,
                    PerformerName = (await _dbContext.Performers.FindAsync(song.PerformerId)).Name,
                };

                model.Songs.Add(singleViewModel);
            }

            return(View(model));
        }
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var performer = await _dbContext.Performers.FindAsync(id);

            if (performer == null)
            {
                return(NotFound());
            }

            var model = new PerformersDetailViewModel
            {
                PerformerInformation = new PerformersViewModel()
                {
                    Id           = performer.Id,
                    Name         = performer.Name,
                    Description  = performer.Description,
                    AlbumsNumber = 0,
                    SongsNumber  = 0
                },
                Albums = new List <AlbumsDetailViewModel>()
            };

            foreach (var album in _dbContext.Albums.Where(x => x.PerformerId == id))
            {
                var songs = _dbContext.Songs.Where(x => x.AlbumId == album.Id);

                var songsViewModel = new List <SongsViewModel>();

                foreach (var song in songs)
                {
                    var singleSongVM = new SongsViewModel()
                    {
                        Id       = song.Id,
                        Name     = song.Name,
                        Duration = FormatDuration(song.DurationSeconds)
                    };

                    songsViewModel.Add(singleSongVM);
                }

                model.Albums.Add(new AlbumsDetailViewModel()
                {
                    AlbumInformation = new AlbumsViewModel()
                    {
                        Id            = album.Id,
                        Name          = album.Name,
                        DateOfRelease = album.DateOfRelease
                    },
                    Songs = songsViewModel
                });
            }

            return(View(model));
        }
        public IActionResult AddItem(int?id)
        {
            Catalogue      catalogue = catalogueService.GetById(id);
            SongsViewModel viewModel = new SongsViewModel();

            viewModel.CatalogueId = catalogue.Id;
            return(View(viewModel));
        }
Exemple #7
0
        // delete song from artist index page.
        public ActionResult ArtistDelete(int?id)
        {
            song           song = db.songs.Find(id);
            SongsViewModel ss   = new SongsViewModel();

            ss.ToModel(song);
            return(View(ss));
        }
        public IActionResult AddItem(SongsViewModel viewModel)
        {
            Catalogue catalogue = catalogueService.GetById(viewModel.Id);

            catalogue.Songs.Add(context.Songs.FirstOrDefault(x => x.Id == viewModel.SongId));
            context.Update(catalogue);
            context.SaveChanges();
            return(RedirectToAction(nameof(MyCatalogues)));
        }
Exemple #9
0
        // edit song from artist index
        public ActionResult ArtistEdit(int?id)
        {
            song           ss = db.songs.Find(id);
            SongsViewModel sv = new SongsViewModel();

            sv.ToModel(ss);
            //populate artist and album drop downs for the song
            sv.ArtistNames = new SelectList(db.artists.OrderBy(x => x.artistName), "id", "artistName", ss.artist_id);
            sv.AlbumNames  = new SelectList(db.albums, "id", "albumName", ss.album_id);
            return(View(sv));
        }
Exemple #10
0
        public ActionResult Edit(SongsViewModel song)
        {
            song s = song.FromModel();

            if (ModelState.IsValid)
            {
                db.Entry(s).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(song));
        }
Exemple #11
0
        public async Task <IActionResult> Index([FromServices] Manager manager, bool?roll)
        {
            await manager.LoadIndexAsync();

            if (roll.HasValue && roll.Value)
            {
                manager.Roll();
            }
            var songsViewModel = new SongsViewModel(manager.Songs, manager.SaveData);

            return(View(songsViewModel));
        }
Exemple #12
0
        public ActionResult AlbumEdit(SongsViewModel song)
        {
            //Save the edit to the song and redirect to the album index
            song s = song.FromModel();

            if (ModelState.IsValid)
            {
                db.Entry(s).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("AlbumIndex", new { AlbumID = song.AlbumID, ArtistID = song.ArtistID }));
            }
            return(View(s));
        }
Exemple #13
0
        public ActionResult ArtistEdit(SongsViewModel song)
        {
            song s = song.FromModel();

            if (ModelState.IsValid)
            {
                db.Entry(s).State = EntityState.Modified;
                db.SaveChanges();
                //save edit to song and redirect to artist index
                return(RedirectToAction("ArtistIndex", new { ArtistID = song.ArtistID }));
            }
            return(View(s));
        }
        public async Task <IActionResult> Create(SongsViewModel songModel)
        {
            Song song = new Song()
            {
                Author = _context.Artists.FirstOrDefault(x => x.Id == songModel.Author.Id),
                Lenght = songModel.Lenght,
                Name   = songModel.Name,
                Album  = songModel.Album
            };

            _context.Songs.Add(song);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemple #15
0
        // GET: songs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            song song = db.songs.Find(id);

            if (song == null)
            {
                return(HttpNotFound());
            }
            SongsViewModel sv = new SongsViewModel();

            sv.ToModel(song);
            return(View(sv));
        }
Exemple #16
0
        // Create a new song
        public ActionResult Create(int AlbumID = 0, int ArtistID = 0)
        {
            //get initial list of albums populated
            List <AlbumViewModel> AlbumsList = UpdatedAlbumsList(ArtistID);
            //Apply attributes to our Song model.
            SongsViewModel sv = new SongsViewModel();

            sv.ArtistNames = new SelectList(db.artists.OrderBy(x => x.artistName), "id", "artistName");
            //selects album to be the one that is imported.
            sv.AlbumNames = new SelectList(AlbumsList, "AlbumID", "AlbumName");
            //if the artist and album were preselected, set importedArtist to true.
            if (AlbumID != 0 && ArtistID != 0)
            {
                sv.importedArtist = true;
            }
            return(View(sv));
        }
Exemple #17
0
        public IActionResult Get()
        {
            var songs           = _songsService.GetAll();
            var songsViewModels = new SongsViewModel();

            foreach (var s in songs)
            {
                var newSM = new SongViewModel();
                newSM.Id     = s.Id;
                newSM.Title  = s.Title;
                newSM.Lyrics = s.Lyrics;
                //newSM.Artists = s.Artists;
                newSM.CreatedDate = s.CreatedDate.HasValue?s.CreatedDate.Value:DateTime.Now;

                songsViewModels.Songs.Add(newSM);
            }
            return(Ok(songsViewModels));
        }
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var album = await _dbContext.Albums.FindAsync(id);

            if (album == null)
            {
                return(NotFound());
            }

            var songsVM = new List <SongsViewModel>();

            foreach (var song in _dbContext.Songs.Where(x => x.AlbumId == id))
            {
                var singleSongVM = new SongsViewModel()
                {
                    Id       = song.Id,
                    Name     = song.Name,
                    Duration = FormatDuration(song.DurationSeconds)
                };
                songsVM.Add(singleSongVM);
            }

            var model = new AlbumsDetailViewModel
            {
                AlbumInformation = new AlbumsViewModel()
                {
                    Id            = album.Id,
                    Name          = album.Name,
                    PerformerId   = album.PerformerId,
                    PerformerName = (await _dbContext.Performers.FindAsync(album.PerformerId)).Name,
                    DateOfRelease = album.DateOfRelease,
                    SongsNumber   = 0
                },
                Songs = songsVM
            };

            return(View(model));
        }
 public void Dispose()
 {
     if (SpotlightViewModel != null)
     {
         SpotlightViewModel.Dispose();
     }
     if (MoviesViewModel != null)
     {
         MoviesViewModel.Dispose();
     }
     if (SeriesViewModel != null)
     {
         SeriesViewModel.Dispose();
     }
     if (EpisodesViewModel != null)
     {
         EpisodesViewModel.Dispose();
     }
     if (GamesViewModel != null)
     {
         GamesViewModel.Dispose();
     }
     if (AlbumsViewModel != null)
     {
         AlbumsViewModel.Dispose();
     }
     if (SongsViewModel != null)
     {
         SongsViewModel.Dispose();
     }
     if (ArtistsViewModel != null)
     {
         ArtistsViewModel.Dispose();
     }
     if (MiniSpotlightsViewModel != null)
     {
         MiniSpotlightsViewModel.Dispose();
     }
     if (MiniSpotlightsViewModel2 != null)
     {
         MiniSpotlightsViewModel2.Dispose();
     }
 }
Exemple #20
0
        // GET: songs/Edit/
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            song ss = db.songs.Find(id);

            if (ss == null)
            {
                return(HttpNotFound());
            }
            //get initial list of albums populated
            List <AlbumViewModel> AlbumsList = UpdatedAlbumsList(ss.artist_id);

            SongsViewModel sv = new SongsViewModel();

            sv.ToModel(ss);
            sv.ArtistNames = new SelectList(db.artists.OrderBy(x => x.artistName), "id", "artistName", ss.artist_id);
            sv.AlbumNames  = new SelectList(AlbumsList, "AlbumID", "AlbumName", ss.album_id);
            return(View(sv));
        }
Exemple #21
0
        public ActionResult Create(SongsViewModel song)
        {
            song s = song.FromModel();

            if (ModelState.IsValid)
            {
                db.songs.Add(s);
                db.SaveChanges();
                //if the song was preselected to belong in an album, redirect to that album.
                if (song.importedArtist == true)
                {
                    return(RedirectToAction("AlbumIndex", new { AlbumID = song.AlbumID, ArtistID = song.ArtistID }));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            song.ArtistNames = new SelectList(db.artists.OrderBy(x => x.artistName), "id", "artistName");
            song.AlbumNames  = new SelectList(db.albums, "id", "name");
            return(View(song));
        }
		public SongsViewController ()
		{
			Title = "Songs";
			TableView.Source = new ViewModelDataSource<Song> {
				CellForItem = (tv,item) => {
					var cell = tv.DequeueReusableCell<SongCell>(SongCell.Key);
					cell.Song = item;
					return cell;
				},
				ViewModel = (viewModel = new SongsViewModel()),
			};

			TableView.TableHeaderView = progressView = new UIProgressView (UIProgressViewStyle.Bar) {
				Alpha = 0f
			};

			progressView.SizeToFit ();

			viewModel.ItemsChanged += (sender, e) => {
				// TODO: Step 2b - update UI 1/sec vs. each notification
				if ((DateTime.Now - lastUpdate).TotalSeconds >= 1) {
					InvokeOnMainThread(() => {
						Console.WriteLine("Reloading the TableView.");
						TableView.ReloadData();
					});
					lastUpdate = DateTime.Now;
				}
			};

			viewModel.SongsUpdated += progress => 
				InvokeOnMainThread(() => {
					Console.WriteLine("{0:P}", progress);
					progressView.Progress = progress;
					progressView.Alpha = progress >= 1f ? 0 : 1;
				});

		}
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var catalog = await _dbContext.Catalogs.FindAsync(id);

            if (catalog == null)
            {
                return(NotFound());
            }

            var model = new CatalogsDetailViewModel();

            model.CatalogInformation = new CatalogsViewModel()
            {
                Id          = catalog.Id,
                Name        = catalog.Name,
                Descritpion = catalog.Description,
                MyUserId    = catalog.MyUserId,
                MyUserName  = (await _dbContext.Users.FindAsync(catalog.MyUserId)).UserName
            };

            var allSongs               = _dbContext.Songs;
            var allAviableSongs        = allSongs;
            var currentUserId          = _userManager.GetUserId(HttpContext.User);
            var currentCatalogAllSongs = _dbContext.CatalogSong.Where(x => x.CatalogId == id).ToList();

            model.CurrentCatalogSongs = new List <SongsViewModel>();
            model.NotAddedSongs       = new List <SongsViewModel>();

            foreach (var song in allSongs)
            {
                if (currentCatalogAllSongs.Any(x => x.SongId == song.Id))
                {
                    var singleViewModel = new SongsViewModel()
                    {
                        Id            = song.Id,
                        Name          = song.Name,
                        Duration      = FormatDuration(song.DurationSeconds),
                        AlbumId       = song.AlbumId,
                        PerformerId   = song.PerformerId,
                        AlbumName     = (await _dbContext.Albums.FindAsync(song.AlbumId)).Name,
                        PerformerName = (await _dbContext.Performers.FindAsync(song.PerformerId)).Name
                    };

                    model.CurrentCatalogSongs.Add(singleViewModel);
                }
                else
                {
                    var singleViewModel = new SongsViewModel()
                    {
                        Id            = song.Id,
                        Name          = song.Name,
                        Duration      = FormatDuration(song.DurationSeconds),
                        AlbumId       = song.AlbumId,
                        PerformerId   = song.PerformerId,
                        AlbumName     = (await _dbContext.Albums.FindAsync(song.AlbumId)).Name,
                        PerformerName = (await _dbContext.Performers.FindAsync(song.PerformerId)).Name
                    };

                    model.NotAddedSongs.Add(singleViewModel);
                }
            }

            return(View(model));
        }
Exemple #24
0
 public SongsView(string theUsername, int count = -1)
 {
     SongsModel     = new SongsViewModel(theUsername, count);
     BindingContext = SongsModel;
     InitializeComponent();
 }
Exemple #25
0
        public SongsPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new SongsViewModel();
        }