Beispiel #1
0
        // GET: Band
        public async Task <IActionResult> Index(DetailBandViewModel viewModel)
        {
            viewModel.Bands = await _context.Bands.OrderBy(x => x.Name).ToListAsync();

            foreach (var item in viewModel.Bands)
            {
                item.Name = item.Name.ToUpper();
            }

            viewModel.BandArtists = await _context.BandArtists.Include(x => x.Artist).ToListAsync();

            return(View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Search(DetailBandViewModel viewModel)
        {
            if (!string.IsNullOrEmpty(viewModel.BandSearch))
            {
                viewModel.Bands = await _context.Bands
                                  .Where(b => b.Name.Contains(viewModel.BandSearch)).ToListAsync();
            }
            else
            {
                viewModel.Bands = await _context.Bands.ToListAsync();
            }

            return(View("Index", viewModel));
        }
Beispiel #3
0
        // GET: Band/Details/5
        public async Task <IActionResult> Details(int?id, DetailBandViewModel viewModel)
        {
            if (id == null)
            {
                return(NotFound());
            }

            viewModel.Band = await _context.Bands
                             .Include(x => x.Albums)
                             .FirstOrDefaultAsync(m => m.BandID == id);

            viewModel.BandArtists = _context.BandArtists.Where(x => x.BandID == viewModel.Band.BandID)
                                    .Include(x => x.Artist)
                                    .Include(x => x.Role);

            if (viewModel.Band == null)
            {
                return(NotFound());
            }

            return(View(viewModel));
        }
Beispiel #4
0
 // View de DetailBand
 public DetailBand(Band band)
 {
     InitializeComponent();
     BindingContext = new DetailBandViewModel(band);
 }