Esempio n. 1
0
        public List <PlayerListViewModel> GetFreePlayers()
        {
            var playerProcessor = new PlayerProcessor();
            int idClub          = 2;
            var players         = new List <PlayerListViewModel>();

            try
            {
                var myPlayers = playerProcessor.RetrieveFreePlayers();

                foreach (var item in myPlayers)
                {
                    PlayerListViewModel player = new PlayerListViewModel();
                    player.setId(item.Id);
                    player.setFirstName(item.FirstName);
                    player.setLastName(item.LastName);

                    players.Add(player);
                }
            }
            catch (Exception e)
            {
                //players = null;
            }

            return(players);
        }
Esempio n. 2
0
        public ActionResult Index(int?page, int?pageItems)
        {
            int idClub;

            try
            {
                Organization myClub = Session["MyClub"] as Organization;
                idClub = myClub.Id;
            }
            catch (Exception e)
            {
                idClub = 2;
            }
            var userProcessor = new UserProcessor();

            var players = new List <PlayerListViewModel>();

            try
            {
                var myPlayers = userProcessor.GetClubPlayers(idClub);

                foreach (var item in myPlayers)
                {
                    PlayerListViewModel player = new PlayerListViewModel();
                    player.setId(item.Id);
                    player.setFirstName(item.FirstName);
                    player.setLastName(item.LastName);

                    players.Add(player);
                }
            }
            catch (Exception e)
            {
                //players = null;
            }

            //<Broj stavki po stranici>
            List <SelectListItem> items = new List <SelectListItem> {
                new SelectListItem {
                    Text = "10", Value = "10"
                },
                new SelectListItem {
                    Text = "15", Value = "15"
                },
                new SelectListItem {
                    Text = "20", Value = "20"
                }
            };

            ViewData["ItemsPerPage"] = new SelectList(items, "Value", "Text", pageItems);

            ViewBag.CurrentPageSize = pageItems ?? 10;
            //</Broj stavki po stranici>

            //<Paginacija>
            int pageSize   = (pageItems ?? 10);
            int pageNumber = (page ?? 1);

            //</Paginacija>

            return(View(players.ToPagedList(pageNumber, pageSize)));
        }