Beispiel #1
0
        // GET: Rent
        public ViewResult Index(string searchString, int?page)
        {
            IEnumerable <Friend> friends;
            IEnumerable <Game>   games = _appServiceGame.GetAllAvaliableGames().OrderBy(game => game.Title);

            if (searchString != null)
            {
                friends = _appServiceFriend.GetAll().Where(s => s.FirstName.Trim().ToUpper().Contains(searchString.Trim().ToUpper())).OrderBy(friend => friend.FirstName);
                page    = 1;
            }
            else
            {
                friends = _appServiceFriend.GetAll().OrderBy(friend => friend.FirstName);
            }

            var friendViewModel = Mapper.Map <IEnumerable <Friend>, IEnumerable <FriendViewModel> >(friends);
            var gameViewModel   = Mapper.Map <IEnumerable <Game>, IEnumerable <GameViewModel> >(games);

            RentViewModel rentViewModel = new RentViewModel
            {
                Friends   = friendViewModel,
                Games     = gameViewModel,
                PageCount = 5
            };

            int pageNumber = (page ?? 1);

            return(View(rentViewModel));
        }
Beispiel #2
0
        // GET: Friend
        public ActionResult Index()
        {
            var friends         = _appServiceFriend.GetAll().OrderBy(friend => friend.FirstName);
            var friendViewModel = Mapper.Map <IEnumerable <Friend>, IEnumerable <FriendViewModel> >(friends);

            return(View(friendViewModel));
        }