Esempio n. 1
0
        public async Task <AllTracksViewModel> Index(string userId, string searchTerm, int p, int s)
        {
            var allTracks = _context.Albums.Where(x => x.Artist.UserId == userId).SelectMany(x => x.Tracks);

            if (!string.IsNullOrWhiteSpace(searchTerm))
            {
                allTracks = allTracks.Where(a => a.Name.ToLower().Contains(searchTerm.ToLower()));
            }

            var result = new AllTracksViewModel
            {
                Tracks = allTracks
                         .OrderBy(x => x.Name)
                         .Skip(p * s - s)
                         .Take(s)
                         .ToList(),
                SearchTerm = searchTerm,
                PageNum    = p,
                PageSize   = s,
                TotalRec   = allTracks.ToList().Count(),
                UserId     = userId
            };

            return(result);
        }
 public AllTracksPage(int?artistId, int?genreId)
 {
     InitializeComponent();
     BindingContext  = vm = new AllTracksViewModel();
     vm.ThisArtistId = artistId;
     vm.ThisGenreId  = genreId;
     vm.InitCommand.Execute(null);
 }
Esempio n. 3
0
        public async Task <AllTracksViewModel> AllTracks(int albumId)
        {
            var tracks = await _context.Tracks.Where(x => x.AlbumId == albumId).ToListAsync();

            var result = new AllTracksViewModel
            {
                Tracks = tracks.OrderBy(x => x.Id).ToList(),
            };

            return(result);
        }
Esempio n. 4
0
 public AllTracksView()
 {
     this.InitializeComponent();
     ViewModel = new AllTracksViewModel();
 }