//
        // GET: /Store/

        public ActionResult Index()
        {
            var genres = new List<String> { "Rock", "Jazz", "Country", "Pop", "Disco" };
            var viewModel = new StoreIndexViewModel
            {
                NumberOfGenres = genres.Count(),
                Genres = genres
            };

            return View(viewModel);
        }
Пример #2
0
        //
        // GET: /Store/
        public ActionResult Index()
        {
            // Create a list of genres
            List<string> genres = new List<string>() { "Rock", "Jazz", "Country", "Pop", "Disco" };

            // Create our View Model
            StoreIndexViewModel viewModel = new StoreIndexViewModel() { NumberOfGenres = genres.Count, Genres = genres };

            ViewBag.Starred = new List<string> { "Rock", "Jazz" };

            return this.View(viewModel);
        }
Пример #3
0
        //
        // GET: /Store/

        public ActionResult Index()
        {
            // Create list of genres
            var genres = this.service.GetGenreNames();

            // Create your view model
            var viewModel = new StoreIndexViewModel
            {
                Genres = genres.ToList(),
                NumberOfGenres = genres.Count()
            };

            return View(viewModel);
        }
        //
        // GET: /Store/
        public ActionResult Index()
        {
            // Create a list of genres
            var genres = new List<string> { "Rock", "Jazz", "Country", "Pop", "Disco" };

            // Create our view model
            var viewModel = new StoreIndexViewModel
            {
                NumberOfGenres = genres.Count(),
                Genres = genres
            };

            return this.View(viewModel);
        }
Пример #5
0
        //
        // GET: /Store/

        public ActionResult Index()
        {
            // Retrieve the list of genres
            var genres = from genre in storeDB.Genres
                         select genre.Name;

            // Create your view model
            var viewModel = new StoreIndexViewModel
            {
                Genres = genres.ToList(),
                NumberOfGenres = genres.Count()
            };

            return View(viewModel);
        }
Пример #6
0
        //
        // GET: /Store/

        public ActionResult Index()
        {
            // Retrieve list of Genres from database
            var genres = GetGenres();

            // Set up our ViewModel
            var viewModel = new StoreIndexViewModel()
            {
                Genres = genres,
                NumberOfGenres = genres.Length
            };

            // Return the view
            return View(viewModel);
        }
Пример #7
0
        //
        // GET: /Store/
        public ActionResult Index()
        {
            // Retrieve list of Genres from database
            var genres = from genre in storeDB.Genres
                         select genre.Name;

            // Set up our ViewModel
            var viewModel = new StoreIndexViewModel()
            {
                Genres = genres.ToList(),
                NumberOfGenres = genres.Count()
            };

            // Return the view
            return View(viewModel);
        }
Пример #8
0
        //
        // GET: /Store/

        public ActionResult Index()
        {
            // Retrieve list of Genres from database
            var genres = session.LuceneQuery<Genre>()
                .ToArray();

            // Set up our ViewModel
            var viewModel = new StoreIndexViewModel()
            {
                Genres = genres,
                NumberOfGenres = genres.Length
            };

            // Return the view
            return View(viewModel);
        }
Пример #9
0
        //
        // GET: /Store/

        public ActionResult Index()
        {
            // Create list of genres
            var genres = new List<string> { "Rock", "Jazz", "Country", "Pop", "Disco" };

            // Create your view model
            var viewModel = new StoreIndexViewModel
            {
                NumberOfGenres = genres.Count,
                Genres = genres
            };

            ViewBag.Starred = new List<string> { "Rock", "Jazz" };
            
            return View(viewModel);
        }
Пример #10
0
        //
        // GET: /Store/

        public ActionResult Index()
        {
            // Retrieve the list of genres
            var genres = from genre in storeDB.Genres
                         select genre.Name;

            // Create our view model
            var viewModel = new StoreIndexViewModel
            {
                NumberOfGenres = genres.Count(),
                Genres = genres.ToList()
            };

            ViewBag.Starred = new List<string> { "Rock", "Jazz" };

            return View(viewModel);

        }
        private async Task<StoreIndexViewModel> GetViewModel(int selectedSortMethod = StoreIndexViewModel.sortByName)
        {

            // populate the viewModel and return it
            var viewModel = new StoreIndexViewModel();
            viewModel.SelectedSortMethod = selectedSortMethod;
            switch (viewModel.SelectedSortMethod)
            {
                case StoreIndexViewModel.sortByNumberOfAlbums:
                    viewModel.Genres = storeDB.Genres.Include(g => g.Albums).OrderByDescending(g => g.Albums.Count()).ToList();
                    break;
                case StoreIndexViewModel.sortByName:
                    viewModel.Genres = storeDB.Genres.Include(g => g.Albums).OrderBy(g => g.Name).ToList();
                    break;
                default:
                    viewModel.Genres = storeDB.Genres.Include(g => g.Albums).OrderBy(g => g.Name).ToList();
                    break;
            }
            
            return viewModel;
        }