Esempio n. 1
0
        public RaidModel Save(RaidDOM raidModel)
        {
            var pokemon = pokemonRepository.GetByName(raidModel.PokemonName);
            var creator = userRepository.Get(raidModel.CreatorId);
            var raid    = new RaidDataModel {
                MinimalLevel = raidModel.MinimalLevel, Pokemon = pokemon, Creator = creator, StartsIn = raidModel.StartsIn
            };

            creator.CreatedRaids.Add(raid);
            pokemon.Raids.Add(raid);

            return(new RaidModel(raidRepository.Save(raid)));
        }
Esempio n. 2
0
        public GenericApiResponse <PokemonDto> GetPokemon(string name)
        {
            var pokemon    = _pokemonRepository.GetByName(name);
            var pokemonDto = new PokemonDto();

            _mapper.Map(pokemon, pokemonDto);
            var genericApiResponse = new GenericApiResponse <PokemonDto> {
                Data = pokemonDto
            };

            if (pokemon != null)
            {
                return(genericApiResponse);
            }

            genericApiResponse.Success      = false;
            genericApiResponse.ErrorMessage = ApiErrors.NotFound.GetDescription();
            throw new ApiException(ApiErrors.NotFound);
        }
Esempio n. 3
0
 public MovesDTO GetByName(string name)
 {
     return(repository.GetByName(name));
 }