Esempio n. 1
0
        // GET: Trainers/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var trainer = await repository.GetAsync(id);

            if (trainer == null)
            {
                return(NotFound());
            }

            return(View(trainer));
        }
Esempio n. 2
0
        public async Task <ActionResult <TrainerRelationship> > GetAsync(string name)
        {
            try
            {
                var trainer = await _trainerRepository.GetAsync(name);

                var entries = await _dexEntryRepository.GetTrainerEntriesAsync(name);

                var relationship = new TrainerRelationship
                {
                    Trainer = trainer,
                    Pokémon = entries?.Select(e => new Pokémon {
                        Id = e.PokémonId
                    }).ToList()
                };

                return(Ok(relationship));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e));
            }
        }