public async Task Execute()
        {
            var text = await clipboardProvider.Copy();

            var item = await mediator.Send(new ParseItemCommand(text));

            if (item != null)
            {
                string id;

                if (item.Metadata.Category == Category.Currency)
                {
                    var result = await tradeSearchService.SearchBulk(item);

                    id = result.Id;
                }
                else
                {
                    var result = await tradeSearchService.Search(item);

                    id = result.Id;
                }

                await mediator.Send(new OpenBrowserCommand(new Uri($"{gameLanguageProvider.Language.PoeTradeSearchBaseUrl}{settings.LeagueId}/{id}")));
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> Handle(OpenTradePageCommand request, CancellationToken cancellationToken)
        {
            var text = await clipboardProvider.Copy();

            var item = await mediator.Send(new ParseItemCommand(text));

            if (item != null)
            {
                string id;

                if (item.Category == Category.Currency)
                {
                    var result = await tradeSearchService.SearchBulk(item);

                    id = result.Id;
                }
                else
                {
                    var result = await tradeSearchService.Search(item);

                    id = result.Id;
                }

                await mediator.Send(new OpenBrowserCommand(new Uri($"{gameLanguageProvider.Language.PoeTradeSearchBaseUrl}{settings.LeagueId}/{id}")));

                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public async Task UpdateQuery()
        {
            Results = new ObservableList <PriceItem>();

            if (Filters != null)
            {
                var saveSettings = false;
                foreach (var filter in Filters.SelectMany(x => x.Filters).Where(x => x.Type == nameof(StatFilter)))
                {
                    if (settings.Modifiers.Contains(filter.Id))
                    {
                        if (!filter.Enabled)
                        {
                            saveSettings = true;
                            settings.Modifiers.Remove(filter.Id);
                        }
                    }
                    else
                    {
                        if (filter.Enabled)
                        {
                            saveSettings = true;
                            settings.Modifiers.Add(filter.Id);
                        }
                    }
                }
                if (saveSettings)
                {
                    settings.Save();
                }
            }

            IsFetching = true;
            if (Item.Rarity == Rarity.Currency && staticDataService.GetId(Item) != null)
            {
                QueryResult = await tradeSearchService.SearchBulk(Item);
            }
            else
            {
                QueryResult = await tradeSearchService.Search(Item, GetFilters(), GetStats());
            }
            IsFetching = false;
            if (QueryResult == null)
            {
                IsError = true;
            }
            else if (QueryResult.Result.Any())
            {
                await LoadMoreData();
                await LoadMoreData();
            }

            UpdateCountString();
        }
Ejemplo n.º 4
0
        public async Task UpdateQuery()
        {
            ShowRefresh = false;
            Results     = new ObservableList <PriceItem>();

            if (Filters != null)
            {
                var saveSettings = false;

                var settingMods = Item.Category switch
                {
                    Category.Accessory => settings.AccessoryModifiers,
                    Category.Armour => settings.ArmourModifiers,
                    Category.Flask => settings.FlaskModifiers,
                    Category.Jewel => settings.JewelModifiers,
                    Category.Map => settings.MapModifiers,
                    Category.Weapon => settings.WeaponModifiers,
                    _ => new List <string>(),
                };

                foreach (var filter in Filters.SelectMany(x => x.Filters).Where(x => x.Type == nameof(StatFilter)))
                {
                    if (settingMods.Contains(filter.Id))
                    {
                        if (!filter.Enabled)
                        {
                            saveSettings = true;
                            settingMods.Remove(filter.Id);
                        }
                    }
                    else
                    {
                        if (filter.Enabled)
                        {
                            saveSettings = true;
                            settingMods.Add(filter.Id);
                        }
                    }
                }
                if (saveSettings)
                {
                    switch (Item.Category)
                    {
                    case Category.Accessory: settings.AccessoryModifiers = settingMods; break;

                    case Category.Armour: settings.ArmourModifiers = settingMods; break;

                    case Category.Flask: settings.FlaskModifiers = settingMods; break;

                    case Category.Jewel: settings.JewelModifiers = settingMods; break;

                    case Category.Map: settings.MapModifiers = settingMods; break;

                    case Category.Weapon: settings.WeaponModifiers = settingMods; break;
                    }
                    ;

                    settings.Save();
                }
            }

            IsFetching = true;
            if (Item.Rarity == Rarity.Currency && staticDataService.GetId(Item) != null)
            {
                QueryResult = await tradeSearchService.SearchBulk(Item);
            }
            else
            {
                QueryResult = await tradeSearchService.Search(Item, GetFilters(), GetStats());
            }
            IsFetching = false;
            if (QueryResult == null)
            {
                IsError = true;
            }
            else if (QueryResult.Result.Any())
            {
                await LoadMoreData();
                await LoadMoreData();
            }

            UpdateCountString();
        }
Ejemplo n.º 5
0
        public async Task UpdateQuery()
        {
            ShowRefresh = false;
            Results     = new ObservableList <PriceItem>();

            if (Filters != null)
            {
                var settingMods = Item.Category switch
                {
                    Category.Accessory => settings.Price_Mods_Accessory,
                    Category.Armour => settings.Price_Mods_Armour,
                    Category.Flask => settings.Price_Mods_Flask,
                    Category.Jewel => settings.Price_Mods_Jewel,
                    Category.Map => settings.Price_Mods_Map,
                    Category.Weapon => settings.Price_Mods_Weapon,
                    _ => new List <string>(),
                };

                foreach (var filter in Filters.SelectMany(x => x.Filters))
                {
                    if (settingMods.Contains(filter.Id))
                    {
                        if (!filter.Enabled)
                        {
                            settingMods.Remove(filter.Id);
                        }
                    }
                    else
                    {
                        if (filter.Enabled)
                        {
                            settingMods.Add(filter.Id);
                        }
                    }
                }

                await mediator.Send(new SaveSettingsCommand(settings));
            }

            IsFetching = true;
            if (Item.Rarity == Rarity.Currency && itemStaticDataProvider.GetId(Item) != null)
            {
                QueryResult = await tradeSearchService.SearchBulk(Item);
            }
            else
            {
                QueryResult = await tradeSearchService.Search(Item, GetPropertyFilters(), GetModifierFilters());
            }
            IsFetching = false;
            if (QueryResult == null)
            {
                IsError = true;
            }
            else if (QueryResult.Result.Any())
            {
                await LoadMoreData();
                await LoadMoreData();
            }

            if (!string.IsNullOrEmpty(QueryResult.Id))
            {
                Uri = await mediator.Send(new GetTradeUriQuery(Item, QueryResult.Id));
            }
            else
            {
                Uri = null;
            }

            UpdateCountString();
        }