示例#1
0
 public ActionResult Index()
 {
     var homeViewModel = new HomeViewModel()
     {
         Albums = this.Data.Albums.All()
             .OrderByDescending(x => x.Id)
             .Take(GlobalConstants.AlbumHomePage)
             .Project()
             .To<AlbumViewModel>(),
         Photos = this.Data.Photograph.All()
             .OrderByDescending(x => x.UploadDate)
             .Take(GlobalConstants.PhotoHomePage)
             .Project()
             .To<PhotographViewModel>()
     };
     return View(homeViewModel);
 }
        public ActionResult Index()
        {
            
//            var vm = new HomeViewModel();
//            vm.AllTeams = this.Data.Teams.All().ToList();
//            vm.AllMatches = this.Data.Matches.All().ToList();
            var matches = this.Data.Matches
                .All().OrderByDescending(x => x.Bets.Count)
                .Take(3)
                .Project()
                .To<MatchViewModel>();

            var teams = this.Data.Teams
                .All()
                .OrderByDescending(x => x.Votes.Count)
                .Take(3).Project()
                .To<TeamViewModel>();

            var homeModel = new HomeViewModel { MatchViewModel = matches, TeamViewModel = teams };

            return this.View(homeModel);
        }