Esempio n. 1
0
        public async Task <ActionResult> ListGolfers(Guid id)
        {
            var isExists = await _gameRepo.IsExists(id);

            if (!isExists)
            {
                return(NotFound());
            }

            var model = new List <GameGolferStatusViewModel>();

            var golfers = await _golferRepo.FindAll();

            var  gameGolfers = (await _gameGolferRepo.FindAllGolfersInGame(id)).Select(gg => gg.Golfer.Id);
            Game game        = await _gameRepo.FindByID(id);

            foreach (var golfer in golfers)
            {
                model.Add(new GameGolferStatusViewModel()
                {
                    MatchId  = game.MatchId,
                    GameId   = id,
                    Golfer   = _mapper.Map <Golfer, GolferViewModel>(golfer),
                    IsInGame = gameGolfers.Contains(golfer.Id),
                });
            }

            return(View(model));
        }
Esempio n. 2
0
        // GET: Golfer
        public async Task <ActionResult> Index()
        {
            var golfers = await _repo.FindAll();

            var model = _mapper.Map <List <Golfer>, List <GolferViewModel> >(golfers.ToList());

            return(View(model));
        }