Пример #1
0
        //---------------------------------------------------------------------
        // GET: Players
        public ViewResult Index()
        {
            // Fetches all players.
            //_viewModel = new IndexPlayerViewModel { Players = _context.Players.ToList() };

            _viewModel = new IndexPlayerViewModel {
                Players = _context.Players.Include(p => p.Membership).ToList()
            };
            return(View(_viewModel));
        }
Пример #2
0
        public ActionResult Details(int id)
        {
            try
            {
                // Queries players with a given key ID to get specific player.
                var targetPlayer = new List <Player> {
                    _context.Players.SingleOrDefault(p => p.Id == id)
                };

                // Adds that match to a list. Only yields one result.
                _viewModel = new IndexPlayerViewModel {
                    Players = targetPlayer
                };
                return(View(_viewModel));
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e);
                throw new HttpException(404, "Not found.");
            }
        }