Esempio n. 1
0
        // GET: Golfer/Details/5
        public async Task <ActionResult> Details(Guid id)
        {
            var isExists = await _repo.IsExists(id);

            if (!isExists)
            {
                return(NotFound());
            }
            var golfer = await _repo.FindByID(id);

            var model = _mapper.Map <GolferViewModel>(golfer);

            return(View(model));
        }
Esempio n. 2
0
        public async Task <ActionResult> AddGolferToGame(Guid id, Guid golferid)
        {
            var isExists = await _gameGolferRepo.CheckGolferInGame(id, golferid);

            if (!isExists)
            {
                Golfer golfer = await _golferRepo.FindByID(golferid);

                Game game = await _gameRepo.FindByID(id);

                GameGolferViewModel newGolferInGame = new GameGolferViewModel
                {
                    Game         = game,
                    Golfer       = golfer,
                    GameHandicap = golfer.Handicap,
                };
                var addGolfer = _mapper.Map <GameGolfer>(newGolferInGame);
                await _gameGolferRepo.Create(addGolfer);
            }

            return(RedirectToAction(nameof(ListGolfers), new { id }));
        }