Exemple #1
0
        async void GetBidder()
        {
            bool changes = false;
            List <BidHistoryItem> bidHistoryItems = new List <BidHistoryItem>();

            foreach (var bidHistory in BidHistory.BidHistoryItems)
            {
                if (String.IsNullOrWhiteSpace(bidHistory.Bid.Bidder))
                {
                    var bidder = await _dataService.GetBidder(bidHistory.Bid.DetailUrl, bidHistory.Bid.BidCount);

                    if (!String.IsNullOrWhiteSpace(bidder))
                    {
                        changes = true;
                        bidHistory.Bid.Bidder = bidder;
                        bidHistoryItems.Add(new BidHistoryItem {
                            Bid = bidHistory.Bid, DateTime = bidHistory.DateTime
                        });
                    }
                }
            }

            if (changes)
            {
                _dataService.UpdateBidHistory(bidHistoryItems);
            }

            Bids = _dataService.GetCurrentBidsFromHistory();
            App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE
            {
                BidViewModel.SetBids(Bids);
                BidHistory = _dataService.GetBidHistory();
                ContentContainerViewModel.SetBidHistory(BidHistory);
            });
        }
Exemple #2
0
        public MainContentViewModel(IEventAggregator eg, IAuctionWebScraperFactory auctionWebScraperFactory)
        {
            EventAggregator           = eg;
            _auctionWebScraperFactory = auctionWebScraperFactory;

            EventAggregator.GetEvent <AuctionNewResponeEvent>().Subscribe(NewBidResponse);

            Bids = new ObservableCollection <Bid>();



            _dataService = new DataService();
            _dataService.Initialize();
            Bids       = _dataService.GetCurrentBidsFromHistory();
            BidData    = _dataService.GetBidData();
            BidHistory = _dataService.GetBidHistory();
            GetBidder();
            LoadPictureUrl();

            BidViewModel = new BidViewModel(Bids, BidData, BidHistory);
            ContentContainerViewModel = new ContentContainerViewModel(BidViewModel, BidHistory);


            ScrapeCommand      = new ActionCommand(Scrape);
            SaveBidDataCommand = new ActionCommand(SaveBidData);
            SetTimer();
        }
 public ContentContainerViewModel(BidViewModel bidViewModel, BidHistory bidHistory)
 {
     BidViewModel   = bidViewModel;
     RecentActivity = new RecentBidActivityViewModel(bidHistory);
     AddTabItem(BidViewModel);
     AddTabItem(RecentActivity);
 }
Exemple #4
0
        void NewBidResponse(List <Bid> bids)
        {
            var changes = _dataService.CheckForBidChanges(Bids.ToList(), bids);

            if (changes)
            {
                Bids = _dataService.GetCurrentBidsFromHistory();

                App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE
                {
                    BidViewModel.SetBids(Bids);
                    BidHistory = _dataService.GetBidHistory();
                    ContentContainerViewModel.SetBidHistory(BidHistory);
                });
            }
            GetBidder();
        }