예제 #1
0
        protected override async Task Handle(ValueRetailRouteCommand command)
        {
            var villages = _valueRetailVillageRepository.GetAll();

            foreach (var village in villages)
            {
                await FetchAndSaveRoutes(village);
            }
        }
예제 #2
0
        protected override async Task Handle(ChauffeurDrivenCommand command)
        {
            var villages = _valueRetailVillageRepository.GetAll();

            foreach (var village in villages)
            {
                var httpRequest = new ValueRetailCommanRequestModel
                {
                    from        = DateTime.UtcNow,
                    cultureCode = village.CultureCode,
                    villageCode = village.VillageCode
                };

                var routeResponseString = await _valueRetailAPI.GetValueRetailAPIData(httpRequest, "Routes", "ChauffeurDriven");

                ChauffeurDrivenRouteResponse chauffeurDrivenRouteResponse = Mapper <ChauffeurDrivenRouteResponse> .MapFromJson(routeResponseString.Result);

                if (chauffeurDrivenRouteResponse.RequestStatus.Success)
                {
                    foreach (var route in chauffeurDrivenRouteResponse.Routes)
                    {
                        var @event = SaveToEvent(route, village);
                        if (objectComparersFactory.GetObjectsComparer <Event>().Compare(@event, new Event()))
                        {
                            throw new TaskCanceledException("Data Insertion Failed for Value Retail Chauffeur Drive.");
                        }
                        else
                        {
                            var cityAndCurrency = await SaveCityStateCountry(route, village);

                            var eventVenueMapping = SaveToVenue(route, @event, cityAndCurrency);
                            SaveDepartureLocations(route, eventVenueMapping);
                            var eventDetail = SaveToEventDetails(@event, eventVenueMapping);
                            SaveTicketDetail(route, eventDetail, cityAndCurrency);
                            SaveBlockedDates(route, @event, eventDetail);
                        }
                    }
                }
            }
        }