Example #1
0
        public async Task <IActionResult> GetAllPokemonCatchesByGuidRange([FromBody] GuidSyncDTO pokemon)
        {
            List <PokemonCatch> pokemonCatches = await unitOfWork.PokemonCatches.GetAllByGuidRange(pokemon.PokemonCatches);

            List <PokemonMoveCatch> pokemonMoveCatches = new List <PokemonMoveCatch>();

            foreach (var pokemonCatch in pokemonCatches)
            {
                List <PokemonMoveCatch> foundMoveCatches = await unitOfWork.PokemonMoveCatches.GetAllByPokemonCatchId(pokemonCatch.Id);

                pokemonMoveCatches.AddRange(foundMoveCatches);
            }

            PokemonCatchSyncDTO syncDTO = new PokemonCatchSyncDTO
            {
                UserId             = pokemon.UserId,
                PokemonCatches     = pokemonCatches,
                PokemonMoveCatches = pokemonMoveCatches
            };

            return(Ok(syncDTO));
        }
Example #2
0
        public async Task <IActionResult> AddRangePokemonCatches([FromBody] PokemonCatchSyncDTO pokemon)
        {
            await Task.Delay(0);

            try
            {
                foreach (var poke in pokemon.PokemonCatches)
                {
                    AddPokemonCatch(poke);                                         //moet gerefactored worden
                }
                //foreach (var move in pokemon.PokemonMoveCatches) unitOfWork.PokemonMoveCatches.AddPokemonMoveCatch(move);//alternatief op aanspreken van andere controller

                var moveCatchesController = new PokemonMoveCatchesController(_dbc, _m, new PokemonMoveCatchRepository(_dbc, _m), _hostingEnvironment);
                foreach (var move in pokemon.PokemonMoveCatches)
                {
                    moveCatchesController.Add(move);
                }
                return(Ok(Guid.Parse("00000000-0000-0000-0000-000000000001")));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error"));
            }
        }