コード例 #1
0
        public async Task <ServiceResponse> GetRaidList(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, string pokemonNameOrLevel, FenceConfiguration[] fences, string orderType, int interactiveLimit, Func <RaidListInfo, string> formatResult)
        {
            var order     = GetRaidListOrder(orderType);
            var startTime = Instant.FromDateTimeUtc(new DateTime(2018, 5, 1, 0, 0, 0).ToUniversalTime()).ToUnixTimeSeconds();

            if (int.TryParse(pokemonNameOrLevel, out int raidLevel))
            {
                if (raidLevel < 1)
                {
                    return(new ServiceResponse <RaidListInfo>(false, LocalizationService.Get(textResource, "Raids_Errors_LevelToLow"), null));
                }
                if (raidLevel > 5)
                {
                    return(new ServiceResponse <RaidListInfo>(false, LocalizationService.Get(textResource, "Raids_Errors_LevelToHigh"), null));
                }

                // Query Level
                var raids = await RaidRepository.FindAllWithGymsAsync(e => e.TimeSpawn > startTime && e.Level == raidLevel);

                return(await GetListResult(raidLevel, null, raids, order, formatResult));
            }
            else
            {
                var pokemonResponse = await PokemonService.GetPokemonAndRaidbossAsync(textResource, pokemonNameOrLevel,
                                                                                      interactiveLimit,
                                                                                      (selectedPokemonName) =>
                                                                                      GetRaidList(textResource, requestStartInUtc, userZone, selectedPokemonName, fences, orderType, interactiveLimit, formatResult));

                if (!pokemonResponse.IsSuccess)
                {
                    return(pokemonResponse);
                }

                var pokemonAndRaidboss = pokemonResponse.Result;
                var raidboss           = pokemonAndRaidboss.Raidboss;
                // Query Raidboss
                var raids = await RaidRepository.FindAllWithGymsAsync(e => e.TimeSpawn > startTime && e.PokemonId == raidboss.Id);

                return(await GetListResult(raidboss.Level, pokemonAndRaidboss, raids, order, formatResult));
            }
        }