private ActionResult PartialArtistsView(IEnumerable <ApplicationUser> artists) { if (!artists.Any()) { return(Content(HttpStatusCode.NoContent.ToString())); } var gigsPerFormByArtists = _unitOfWork.Gigs .GetCountOfUpcomingGigsPerformedBy(artists.Select(a => a.Id), AppConst.CountOfGigPerLoad); var userId = User.Identity.GetUserId(); var attendances = _unitOfWork.Attendances.GetFutureAttendances(userId) .ToLookup(a => a.GigId); var followings = _unitOfWork.Followings.GetFolloweesFor(userId) .ToLookup(f => f.Followee.Id); var artistsViewModel = new ArtistsViewModel { Artists = artists, Gigs = gigsPerFormByArtists, Attendances = attendances, Followings = followings }; return(PartialView("_MoreArtists", artistsViewModel)); }
public ArtistsController( IMusicProvider musicProvider, ArtistsViewModel.Factory artistsViewModelFactory, AlbumViewModel.Factory albumViewModelFactory, ArtistViewModel.Factory artistViewModelFactory) { _musicProvider = musicProvider; _artistsViewModelFactory = artistsViewModelFactory; _albumViewModelFactory = albumViewModelFactory; _artistViewModelFactory = artistViewModelFactory; }
public ActionResult Index() { var userId = User.Identity.GetUserId(); var artists = _unitOfWork.Users.GetUsers().Where(a => a.Id != userId); var viewModel = new ArtistsViewModel { Artists = artists, ShowAction = true, Heading = "All Artists" }; return(View("Artists", viewModel)); }
public ActionResult Followings() { var userId = User.Identity.GetUserId(); var artists = _unitOfWork.Users.GetFolloweesByUserId(userId); var viewModel = new ArtistsViewModel { Artists = artists, ShowAction = false, Heading = "Artists I'm Followings" }; return(View("Artists", viewModel)); }
// GET: Artists/Details/5 public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(NotFound()); } var artist = await _context.Artist .Include(a => a.AlbumsArtists) .ThenInclude(a => a.Album) .ThenInclude(a => a.Composition) .FirstOrDefaultAsync(m => m.ArtistId == id); if (artist == null) { return(NotFound()); } var albumsDB = _context.AlbumsArtists .Where(a => a.ArtistId == id) .Join ( _context.Album .Include(c => c.AlbumsArtists) .ThenInclude(g => g.Artist), g => g.AlbumId, a => a.AlbumId, (g, a) => new { g, a } ) .Select(ga => ga.a); var albums = await albumsDB.ToListAsync(); ArtistsViewModel artistsView = new ArtistsViewModel(); if (User.Identity.IsAuthenticated) { var currentUserId = new Guid(User.FindFirst(x => x.Type == "id").Value); artistsView = ViewModelConstructor.FavouriteArtists(new List <Artist>() { artist }, _context, currentUserId).First(); } else { artistsView.Artist = artist; } artistsView.Albums = albums; return(View(artistsView)); }
public async Task <ActionResult> Following() { var userId = User.Identity.GetUserId(); var artists = _unitOfWork.Artists.GetArtistsByFollowerIdAsync(userId); ArtistsViewModel viewModel = new ArtistsViewModel { Heading = "Artists I'm Following", ShowActions = false, Artists = PrepareArtistViewModelList(await artists) }; return(View("Artists", viewModel)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var artists = _context.Users .Where(a => a.Followers.Any(f => f.FollowerId == userId)); var viewModel = new ArtistsViewModel() { FollowedArtists = artists, ShowActions = User.Identity.IsAuthenticated, Heading = "Artists I follow" }; return(View(viewModel)); }
public async Task SmokeTest() { var songs = SetupSongsWithArtist("B", "b", "C", "A").ToReadOnlyList(); var songFetcher = Substitute.For <ISongFetcher <NetworkSong> >(); songFetcher.GetSongsAsync().Returns(Observable.Return(songs)); var vm = new ArtistsViewModel <NetworkSong>(songFetcher, "AnyKey"); vm.Activator.Activate(); await vm.LoadCommand.ExecuteAsync(); Assert.Equal(new[] { "A", "B", "C" }.AsEnumerable(), vm.Artists.AsEnumerable()); }
public ActionResult GetArtist() { var userId = User.Identity.GetUserId(); var artists = _context.Followings .Where(a => a.FollowerId == userId) .Include(g => g.Followee) .ToList(); var viewModel = new ArtistsViewModel() { Artists = artists, ShowActions = User.Identity.IsAuthenticated, Heading = "Artists I'm following" }; return(View(viewModel)); }
public static List <ArtistsViewModel> FavouriteArtists(List <Artist> artistsF, MusicOnContext _context, Guid userId) { List <ArtistsViewModel> artists = new List <ArtistsViewModel>(); foreach (var artist in artistsF) { var artistVM = new ArtistsViewModel(); artistVM.Artist = artist; var favourit = _context.FavouriteArtists .Where(f => f.UserId == userId) .FirstOrDefault(f => f.ArtistId == artist.ArtistId); if (favourit != null) { artistVM.IsFavourite = true; } artists.Add(artistVM); } return(artists); }
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(); } }
public async Task FiltersSongsAndStoresThemInLocalCache() { IReadOnlyList <NetworkSong> songs = SetupSongsWithArtist("A", "A", "B").ToList(); var songFetcher = Substitute.For <ISongFetcher <NetworkSong> >(); songFetcher.GetSongsAsync().Returns(Observable.Return(songs)); var vm = new ArtistsViewModel <NetworkSong>(songFetcher, "TheKey"); vm.Activator.Activate(); await vm.LoadCommand.ExecuteAsync(); vm.SelectedArtist = "A"; List <NetworkSong> cached = await BlobCache.LocalMachine.GetObject <List <NetworkSong> >("TheKey"); Assert.Equal(2, cached.Count); Assert.True(cached.All(x => x.Artist == "A")); }
public void TimeoutTriggersthrownExceptions() { var songFetcher = Substitute.For <ISongFetcher <NetworkSong> >(); songFetcher.GetSongsAsync().Returns(Observable.Never <IReadOnlyList <NetworkSong> >()); var vm = new ArtistsViewModel <NetworkSong>(songFetcher, "AnyKey"); vm.Activator.Activate(); var coll = vm.LoadCommand.ThrownExceptions.CreateCollection(); (new TestScheduler()).With(scheduler => { vm.LoadCommand.Execute(null); scheduler.AdvanceByMs(ArtistsViewModel <NetworkSong> .LoadCommandTimeout.TotalMilliseconds + 1); }); Assert.Equal(1, coll.Count); Assert.IsType <TimeoutException>(coll[0]); }
public ArtistsPage() { InitializeComponent(); BindingContext = new ArtistsViewModel(); }
// GET: SearchResults public async Task <IActionResult> Index(string searchString) { var search = new SearchModel(); var compositions = from c in _context.Composition .Include(c => c.Album.AlbumsArtists) .ThenInclude(c => c.Artist) .Include(c => c.Song) select c; if (!String.IsNullOrEmpty(searchString)) { compositions = compositions.Where(s => s.Song.Title.Contains(searchString)); } var compositionsF = await compositions.ToListAsync(); if (User.Identity.IsAuthenticated) { var userId = new Guid(User.FindFirst(x => x.Type == "id").Value); search.Compositions = ViewModelConstructor.FavouriteSongs(compositionsF, _context, userId); } else { foreach (var comp in compositionsF) { var compVM = new CompositionViewModel() { Composition = comp }; search.Compositions.Add(compVM); } } var artists = from c in _context.Artist .Include(c => c.AlbumsArtists) .ThenInclude(c => c.Album) .ThenInclude(c => c.Genre) select c; if (!String.IsNullOrEmpty(searchString)) { artists = artists.Where(s => s.Name.Contains(searchString)); } var artistsF = await artists.ToListAsync(); if (User.Identity.IsAuthenticated) { var userId = new Guid(User.FindFirst(x => x.Type == "id").Value); search.Artists = ViewModelConstructor.FavouriteArtists(artistsF, _context, userId); } else { foreach (var art in artistsF) { var artVM = new ArtistsViewModel() { Artist = art }; search.Artists.Add(artVM); } } var albums = from c in _context.Album .Include(c => c.AlbumsArtists) .ThenInclude(c => c.Artist) select c; if (!String.IsNullOrEmpty(searchString)) { albums = albums.Where(s => s.Title.Contains(searchString)); } search.Albums = await albums.ToListAsync(); var mixTapes = from c in _context.MixTape select c; if (!String.IsNullOrEmpty(searchString)) { mixTapes = mixTapes.Where(s => s.Title.Contains(searchString)); } search.MixTapes = await mixTapes.ToListAsync(); return(View(search)); }
public override void Load() { if (DataContext == null) { DataContext = new ArtistsViewModel(); ((ArtistsViewModel)DataContext).LoadArtists(); } }