Пример #1
0
        async Task When(DealerManifestDownloadsStarted e, IDealerManifestFile file)
        {
            try
            {
                var manifest = await file.Download(_dealer, _pages);

                var added   = new Many <DealerManifest.Campaign>();
                var updated = new Many <DealerManifest.Campaign>();
                //var remainingIds = _campaignsById.Keys.ToHashSet();
                var remainingIds = ManyExtensions.ToHashSet(_campaignsById.Keys);

                foreach (var downloaded in manifest.Campaigns)
                {
                    remainingIds.Remove(downloaded.Id);

                    if (!_campaignsById.TryGetValue(downloaded.Id, out var existing))
                    {
                        added.Write.Add(downloaded);
                    }
                    else
                    {
                        if (downloaded.AssetId != existing.AssetId ||
                            downloaded.Page != existing.Page ||
                            downloaded.Priority != existing.Priority ||
                            downloaded.Required != existing.Required ||
                            downloaded.Link != existing.Link ||
                            downloaded.AltText != existing.AltText ||
                            downloaded.WhenStarts != existing.WhenStarts ||
                            downloaded.WhenEnds != existing.WhenEnds ||
                            downloaded.Model != existing.Model ||
                            downloaded.ModelYear != existing.ModelYear)
                        {
                            updated.Write.Add(downloaded);
                        }
                    }
                }

                Then(new DealerManifestDownloaded(Id, manifest.Assets, added, updated, remainingIds.ToMany()));
            }
            catch (Exception error)
            {
                Then(new DealerManifestDownloadFailed(Id, error.ToString()));
            }
        }
Пример #2
0
 static Many <Id> Route(DealerManifestDownloadsStarted e) => e.DealerIds;
Пример #3
0
 void Given(DealerManifestDownloadsStarted e) =>
 _pendingDealerIds.AddRange(e.DealerIds);