Ejemplo n.º 1
0
        private async Task ProcessBlockAsync(INumericRangeBlockContext blockContext)
        {
            try
            {
                await blockContext.StartAsync();

                var journeys = await _travelDataService.GetJourneysAsync(blockContext.NumericRangeBlock.StartNumber, blockContext.NumericRangeBlock.EndNumber);

                var travelInsights = new List <TravelInsight>();

                foreach (var journey in journeys)
                {
                    var insight = new TravelInsight()
                    {
                        InsightDate   = journey.TravelDate.Date,
                        InsightText   = "Some useful insight",
                        PassengerName = journey.PassengerName
                    };

                    travelInsights.Add(insight);
                }

                await _travelInsightsService.AddAsync(travelInsights);

                int itemCountProcessed = travelInsights.Count;
                await blockContext.CompleteAsync(itemCountProcessed);
            }
            catch (Exception ex)
            {
                await blockContext.FailedAsync(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void ProcessBlock(IDateRangeBlockContext blockContext)
        {
            try
            {
                blockContext.Start();

                var journeys       = _travelDataService.GetJourneys(blockContext.DateRangeBlock.StartDate, blockContext.DateRangeBlock.EndDate);
                var travelInsights = new List <TravelInsight>();

                foreach (var journey in journeys)
                {
                    var insight = new TravelInsight()
                    {
                        InsightDate   = journey.TravelDate.Date,
                        InsightText   = "Some useful insight",
                        PassengerName = journey.PassengerName
                    };

                    travelInsights.Add(insight);
                }

                _travelInsightsService.Add(travelInsights);

                int itemCountProcessed = travelInsights.Count;
                blockContext.Complete(itemCountProcessed);
            }
            catch (Exception ex)
            {
                blockContext.Failed(ex.ToString());
            }
        }
        private TravelInsight ExtractInsight(Journey journey)
        {
            var insight = new TravelInsight()
            {
                InsightDate   = journey.TravelDate.Date,
                InsightText   = "Some useful insight",
                PassengerName = journey.PassengerName
            };

            return(insight);
        }
        private void ProcessBlock(IDateRangeBlockContext blockContext)
        {
            try
            {
                blockContext.Start();

                var journeys = _travelDataService.GetJourneys(blockContext.DateRangeBlock.StartDate, blockContext.DateRangeBlock.EndDate);
                var travelInsights = new List<TravelInsight>();

                foreach (var journey in journeys)
                {
                    var insight = new TravelInsight()
                    {
                        InsightDate = journey.TravelDate.Date,
                        InsightText = "Some useful insight",
                        PassengerName = journey.PassengerName
                    };

                    travelInsights.Add(insight);
                }

                _travelInsightsService.Add(travelInsights);

                int itemCountProcessed = travelInsights.Count;
                blockContext.Complete(itemCountProcessed);
            }
            catch (Exception ex)
            {
                blockContext.Failed(ex.ToString());
            }
        }
        private TravelInsight ExtractInsight(Journey journey)
        {
            var insight = new TravelInsight()
            {
                InsightDate = journey.TravelDate.Date,
                InsightText = "Some useful insight",
                PassengerName = journey.PassengerName
            };

            return insight;
        }
Ejemplo n.º 6
0
 public async Task NotifyUserAsync(TravelInsight travelInsight)
 {
     // send a push notification or something
     await Task.Yield();
 }
Ejemplo n.º 7
0
 public void NotifyUser(TravelInsight travelInsight)
 {
     // send a push notification or something
 }